应该看得懂吧,把cookie换成自己的就好了。
#!/usr/bin/env python#coding=utf8""" Simulate a user login to Sina Weibo with cookie.You can use this method to visit any page that requires login."""import urllib2import sysimport reimport timecookie = '' # get your cookie from Chrome or Firefoxheaders = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0', 'cookie': cookie}C = open("Res.txt","w")def visit(url): time.sleep(1) req = urllib2.Request(url, headers=headers) text = urllib2.urlopen(req).read() text2 = "" for x in text: if x == '\\': continue text2 += x # print the title, check if you login to weibo sucessfully pat_title = re.compile(r'