Python Mechanize won't open these sites

前端 未结 1 2016
太阳男子
太阳男子 2020-12-18 01:42

I\'m working with Python\'s Mechanize module. I\'ve come across 3 different sites that cannot be opened by mechanize directly:

  1. en.wikipedia.org/wiki/Dog (new u
相关标签:
1条回答
  • 2020-12-18 02:14

    In the case of the cpsc.gov site, it looks like there's a refresh header that isn't being correctly processed by mechanize HTTPRefreshProcessor. However, you can workaround the problem as follows:

    import mechanize
    
    url = 'http://www.cpsc.gov/cpscpub/prerel/prhtml03/03059.html'
    br = mechanize.Browser()
    br.set_handle_refresh(False)
    br.open(url)
    
    0 讨论(0)
提交回复
热议问题