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
| import urllib import urllib2 for i in range(1,11): url = "http://m.weibo.cn/mblogDeal/addAMblog"
data = "content=发十次之"+str(i)+"&st=ceb309"
headers = {'Host': 'm.weibo.cn', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-cn', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Origin': 'http://m.weibo.cn', 'Content-Length': '26', 'Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56', 'Referer': 'http://m.weibo.cn/mblog', 'Cookie': '不准看'}
req = urllib2.Request(url, data, headers)
try: response = urllib2.urlopen(req) print(i) except: print('error!') exit()
print(response.read())
|