我正在使用 mechanize 库来模拟浏览器以获取 html,如下所示,但时不时地我不断收到错误...
代码出错:
post_url = "http://www.stackoverflow.com/"
browser = mechanize.Browser()
browser.set_handle_robots(False)
browser.addheaders = [('User-agent', 'Firefox')]
html = browser.open(post_url).read().decode('UTF-8')
错误:
Traceback (most recent call last):
File "C:\test.py", line 1538, in <module>
periodically(180, -60, +60, getData)
File "C:\test.py", line 262, in periodically
s.run()
File "C:\Python27\lib\sched.py", line 117, in run
action(*argument)
File "C:\test.py", line 1241, in getData
html = browser.open(post_url).read().decode('UTF-8')
File "build\bdist.win32\egg\mechanize\_mechanize.py", line 203, in open
return self._mech_open(url, data, timeout=timeout)
File "build\bdist.win32\egg\mechanize\_mechanize.py", line 255, in _mech_open
raise response
httperror_seek_wrapper: HTTP Error 500: Internal Server Error
>>>
任何人都知道如何修复它/解决这个错误?