代碼簡(jiǎn)陋,沒(méi)有技術(shù),需要txt簡(jiǎn)介才能使用。但是,沒(méi)有發(fā)送概要文件。如果仔細(xì)看代碼,很容易猜到。希望大家不要拿去擦。因?yàn)檎娴暮軣o(wú)趣。
代碼所需的相關(guān)python模塊方法包括urllib、urllib2、cookie lib、hashlib、threading、re、OS、time和random。真的需要很多方法。
#-*-代碼: utf-8-*-
Importurllib、urllib2、cookie lib、散列l(wèi)ib、threading
Import re、os、time、random
Import sys
Reload(sys)
(' utf8 ')
Def log(s):
S='\n' str(s)
F=open('log.txt ',' a ')
F.write(s)
F.close()
(s)
()
Class WeiboCn:
All=(“蛇網(wǎng)python學(xué)習(xí)平臺(tái)~ ~ ~ ~”“果斷關(guān)注~”“不知道你有沒(méi)有發(fā)現(xiàn)還有一個(gè)你的粉絲?!肮?!”)。
URL=';
標(biāo)頭={
用戶代理“:”Mozilla(windows nt 5.1;RV :2 . 0 . 1)gecko/2010 01 01 Firefox;而且,
}
Def _ _ init _ _ (self,username,password,keyword=none,* args) :
=username
=keyword
=args or
=cookielib。LWPCookieJar()
=urllib2.build_opener())
Urllib2.install_opener()
(username、password)
Def try login (self、username、password) :
Bodies=dict(_=in()),callback=';client=')',entry=' miniblog ',user=' jiangjia @ 1616.net ')
Print“登錄前,導(dǎo)入servertime nonce參數(shù)(用于加密密碼生成)”
preloadurl=';Urllib.urlencode(bodies)
Content=(preloadurl)[1]。read()
Bodies=eval('\{ .*?\} ',內(nèi)容)[0])
Password=((password))。hexdigest()。hex digest()str(bodies[' servertime '])bodies
加密“Print”將獲取密碼“% s”% password
Bodies.update (dict (client=')',encoding=' utf-8 ',entry=' miniblog ',gateway=seetFramelogin=1callback=,username=username,useticket=1))
response=(' http://log in . Sina . com.cn/SSO/log in . PHP?Client=)',bodies)[1]
內(nèi)容=re()
more URL=re . find all(' replace \([\ ' | '](.*?)[\' |'] \ ',內(nèi)容)
If len(moreurl)==0: print '登錄失敗!'
Content=(more URL [0],dict(referer=' http://log in . Sina . com.cn/SSO/logi)
n.php?client=)',Host='weibo.com'))[1].read()if username in content:
print "登錄成功!"
()
def afterLogin(self):
content = (';)[1].read()
= re.findall('\$uid.*?"(\d+)"', content)[0]
def care(self):
url = 'http://weibo.com/pub/news?source=toptray'
if :
url = 'http://weibo.com/k/%s?Refer=Index_header' % urllib.quote())
log(url)
content = (url)[1].read()
match = re.findall('loadCommentByRid\((.*?)\)', content)
for x in match:
ownerUid,productId,productName,resourceId,resTitle,resInfo,some,listInDiv,forward,some2 = eval("(%s)" % x)
bodies = dict(uid=ownerUid,fromuid=,refer_sort='profile',atnId='profile')
result = ('http://weibo.com/attention/aj_addfollow.php?refer_sort=profile&atnId=profile&rnd=%f' % random.random(), bodies, dict(Referer = 'http://weibo.com/'))[1].read()
if 'A00006' in result:
log("<%s>關(guān)注<%d>成功!" % (,ownerUid))
content = [random.randint(0, len()-1)]
bodies = dict(content=content,uid=,ownerUid=ownerUid,productId=productId,productName=productName,resourceId=resourceId,resTitle=resTitle,resInfo=resInfo,some=some,listInDiv=listInDiv,forward=forward,some2=some2)
result = ('http://weibo.com/comment/addcomment.php?f=1&rnd=%f' % random.random(), bodies, dict(Referer='http://weibo.com/pub/news?source=toptray'))[1].read()
if 'A00006' in result:
log("<%s>評(píng)論<%d>成功!<%s>" % (,ownerUid, content))
else:
log("<%s>評(píng)論<%d>失敗!" % (,ownerUid))
(30, 4 * 60))
else:
log("<%s>關(guān)注<%d>失敗!" % (,ownerUid))
raise Exception,"關(guān)注<%d>失?。?#34; % ownerUid
def unCare(self):
content = ('http://weibo.com/%s/follow' % str())[1].read()
pages = re.findall('<em>(\d+)<\/em>', content)
log(pages)
if len(pages) == 0:
return
p = apply(max,[int(i) for i in pages])
for i in range(p,0,-1):
log(i)
c
1fff
ontent = ('http://weibo.com/attention/att_list.php?action=0&tag=&page=%d' % i)[1].read()
cancel = re.findall('粉絲<strong>(.*?)</strong>.*?followcancel\(\'(\d+)', content, re.S)
headers = {'Content-Type':'application/x-www-form-urlencoded', 'Origin':';,'Referer':'http://weibo.com/attention/att_list.php?action=0&tag=&page=%d' % i}
url = 'http://weibo.com/attention/aj_delfollow.php?rnd=%f' % random.random()
for fans,id in cancel:
if int(fans) > 2000:
log("取消關(guān)注%s失敗,原因:粉絲數(shù)%s大于2000" % (id, fans))
continue
result = (url, dict(touid=id,fromuid=),headers)[1].read()
if 'A00006' in result:
log("取消關(guān)注%s成功!" % id)
else:
log("取消關(guān)注%s失??!" % id)
(10)
def _request(self, url, bodies = {}, headers = {}):
request = urllib2.Request(url, urllib.urlencode(bodies), headers = headers)
return (request, .open(request))
def _readMainPage(self):
return )[1].read()
class timer):
def __init__(self, weibo):
(self)
def run(self):
#log (">>>>>>當(dāng)前用戶<%s>線程<%s>" % (.user,self.getName()))
#t = in('%H'))
#looptime = 6 * 6 if t < 22 and t > 8 else 60 * 60 * 5
'''
try:
.care()
log ("當(dāng)前用戶<%s>線程<%s>關(guān)注完一頁(yè), 休息%d小時(shí),稍后繼續(xù)~~" % (.user,self.getName(), looptime/3600))
except Exception, e:
log(str(e))
log ("當(dāng)前用戶<%s>線程<%s>出現(xiàn)異常,可能是關(guān)注超過(guò)上限, 休息%d小時(shí),稍后繼續(xù)嘗試~~" % (.user,self.getName(), looptime/3600))
'''
.unCare()
#(looptime)
#()
def run(userinc):
f = open(userinc).readlines()
if len(f) < 1 : log("配置文件為空!")
m = re.compile('\|')
userlist = []
for line in f:
if line.startswith('#'):continue
line = m.spli())
u(line)
allWeibo = [apply(WeiboCn,u) for u in userlist]
pound = []
for w in allWeibo:
w = timer(w)
w.setDaemon(True)
w.start()
(w)
#(10)
for x in pound:
x.join()
if __name__ == '__main__':
run(__file__), 'u;))
'''
while True:
m.runtimes += 1
m.run()
'''
1.《【刷微博粉絲】每天學(xué)一點(diǎn)。簡(jiǎn)單的python刷新浪微博粉絲小程序(包括源代碼)》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識(shí),僅代表作者本人觀點(diǎn),與本網(wǎng)站無(wú)關(guān),侵刪請(qǐng)聯(lián)系頁(yè)腳下方聯(lián)系方式。
2.《【刷微博粉絲】每天學(xué)一點(diǎn)。簡(jiǎn)單的python刷新浪微博粉絲小程序(包括源代碼)》僅供讀者參考,本網(wǎng)站未對(duì)該內(nèi)容進(jìn)行證實(shí),對(duì)其原創(chuàng)性、真實(shí)性、完整性、及時(shí)性不作任何保證。
3.文章轉(zhuǎn)載時(shí)請(qǐng)保留本站內(nèi)容來(lái)源地址,http://f99ss.com/gl/2529932.html