注:weibo这个第三方库目前只支持python2.7 3.3 3.4 三个版本
API_KEY 需要再微博api接口那里申请,审核没通过的应用会显示“未通过审核应用”
下面的代码是在python2.7的版本上编写的
# encoding: utf-8
from weibo import Client
import schedule,time
# API_KEY = ''
# API_SECRET = ''
# REDIRECT_URI = 'http://www.henhaoji.net'
# client = Client(API_KEY, API_SECRET, REDIRECT_URI, username='', password='')
# client.post('statuses/share',status=u'你好微博' + 'http://www.henhaoji.net')
def job():
API_KEY = ''
API_SECRET = ''
REDIRECT_URI = 'http://www.henhaoji.net'
times = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
client = Client(API_KEY, API_SECRET, REDIRECT_URI, username='', password='......')
client.post('statuses/share',status=u'你好,朋友!今天也要加油哦!现在的时间是:' + times + 'http://www.henhaoji.net')
# schedule.every(1).minutes.do(job)
# schedule.every().hour.do(job)
schedule.every().day.at("12:00").do(job)
# schedule.every(5).to(10).days.do(job)
# schedule.every().monday.do(job)
# schedule.every().wednesday.at("13:15").do(job)
while True:
schedule.run_pending()
time.sleep(1)