水仁博客

上善若水,仁恕载物
随笔 - 11, 文章 - 0, 评论 - 4, 引用 - 0
数据加载中……

使用ClientCookie获取IE的Cookie访问页面

有些需要网站需要登录后才能进行一些操作,如果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

posted on 2007-12-28 11:02 水仁圭 阅读(747) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问