Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用Python中的mechanize访问网站_Python_Mechanize - Fatal编程技术网

无法使用Python中的mechanize访问网站

无法使用Python中的mechanize访问网站,python,mechanize,Python,Mechanize,这是我用来打开网站的代码,但代码一直在运行,出现“超时错误”这可能是用户代理的问题。有些网站会检测到它,不允许你连接。尝试修改您的用户代理,看看是否有帮助。感谢您的回复。能否请您指导如何修改用户代理? import mechanize url = 'https://www1.nseindia.com/products/content/equities/equities/eq_security.htm' br = mechanize.Browser() br.set_handle_refresh

这是我用来打开网站的代码,但代码一直在运行,出现“超时错误”

这可能是用户代理的问题。有些网站会检测到它,不允许你连接。尝试修改您的用户代理,看看是否有帮助。感谢您的回复。能否请您指导如何修改用户代理?
import mechanize

url = 'https://www1.nseindia.com/products/content/equities/equities/eq_security.htm'
br = mechanize.Browser()
br.set_handle_refresh(False)
br.set_handle_equiv(False)
br.open(url)