代码简陋没有什么技术,还有个txt的配置文件才可以用。但是配置文件不发出来了。只要你自己好好看代码很容易猜得到。希望大家不要拿去刷了。因为实在是没意思。
代码中需要用到的相关python模块方法有: urllib, urllib2, cookielib, hashlib,threading,re, os, time, random,真的需要不少方法呢。
# -*- coding: utf-8 -*-
import urllib, urllib2, cookielib, hashlib,threading
import re, os, time, random
import sys
reload(sys)
sys.setdefaultencoding('utf8')
def log(s):
s = "\n" + str(s)
f = open('log.txt', 'a+')
f.write(s)
f.close()
sys.stdout.write(s)
sys.stdout.flush()
class WeiboCn:
all = ('玩蛇网python学习平台关注你啦~~~~','果断关注~','不知道你有没有发现你的粉丝多了一个?,哈哈!')
url = 'http://www.weibo.com'
header = {
'User-Agent' : 'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
}
def __init__(self, username, password, keyword = None, *args):
self.user = username
self.keyword = keyword
self.all = args or self.all
self.cj = cookielib.LWPCookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
urllib2.install_opener(self.opener)
self.tryLogin(username, password)
def tryLogin(self, username, password):
bodies = dict(_=int(time.time()),callback='sinaSSOController.preloginCallBack',client='ssologin.js(v1.3.12)',entry='miniblog',user='jiangjia@1616.net')
print "预登录,获取servertime & nonce参数(用来加密生成密码)"
preloadurl = 'http: