from lxml import etree
filename = 'douban.txt'
cookie = cookielib.MozillaCookieJar(filename)
handler = urllib2.HTTPCookieProcessor(cookie)
opener = urllib2.build_opener(handler)
response = opener.open("https://accounts.douban.com/login")
cookie.save(ignore_expires=True, ignore_discard=True)
data = response.read()
treedata = etree.HTML(data)
captcha = treedata.xpath("//img[@id='captcha_image']/@src")
网友评论