使用mechanize废弃websi时发生URLError

2024-10-05 14:22:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用python登录this website并获取信息。 当我使用机械化。我得到了这个错误信息。请帮我解决这个问题。谢谢你

我的代码:

import mechanize
import urllib

site = "https://secure.lme.com/Data/Community/Login.aspx"
br = mechanize.Browser()

#br.set_cookiejar(cookie)
br.set_handle_robots( False )
br.addheaders = [
    ('User-agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36'),
    ('Cache-Control', 'max-age=0'),
    ('Referer', 'https://secure.lme.com/Data/Community/Login.aspx'),
    ('Accept-Encoding', 'gzip, deflate'),
    ('Accept-Language', 'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4'),
    ('Cache-Control','max-age=0')
]
response = br.open(site)
print response

错误如下:

^{pr2}$

Tags: httpscommunitybrimportcomcachedatasite