-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendWeibo.py
executable file
·64 lines (52 loc) · 1.74 KB
/
sendWeibo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
import time
from threading import Timer
import TextFactory
from config import TIME_SLOG, TIMER_REPEAT
from logger import log
class WeiboTask(object):
def __init__(self, http, uid):
super(WeiboTask, self).__init__()
self.http = http
self.uid = uid
def start(self):
log("开始任务")
self.sendWeibo()
if TIMER_REPEAT:
self.newTimer()
def newTimer(self):
self.timer = Timer(TIME_SLOG, self.main, ()).start()
def stop(self):
log("结束任务")
self.timer.cancel()
pass
def main(self):
self.sendWeibo()
if TIMER_REPEAT:
self.newTimer()
def sendWeibo(self):
text = TextFactory.getText()
if text != None:
self.update(text)
log("发送微博:" + text)
else:
log("暂无更新")
def update(self, text):
data = {
"location" : "v6_content_home",
"appkey" : "",
"style_type" : "1",
"pic_id" : "",
"text" : text,
"pdetail" : "",
"rank" : "0",
"rankid" : "",
"module" : "stissue",
"pub_type" : "dialog",
"_t" : "0",
}
self.http.headers["Referer"] = "http://www.weibo.com/u/%s/home?wvr=5" % str(self.uid)
resp = self.http.post(
"http://www.weibo.com/aj/mblog/add?ajwvr=6&__rnd=%d" % int(time.time() * 1000),
data = data
)