有些需要网站需要登录后才能进行一些操作,如果IE存在登录的Cookie,我们就可以通过IE的Cookie访问这些网站内容。
import ClientCookie, urllib2
#the page I want to get
url_string="http://bbs.dict.cn/vocabulary.php?export=xml"
cj = ClientCookie.MSIECookieJar(delayload=True)
cj.load_from_registry()
print cj #I want to know what I get
opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cj))
ClientCookie.install_opener(opener)
f = ClientCookie.urlopen(url_string)
print f.read() # NOT the right page html