Read timeout using either urllib2 or any other http library

后端 未结 8 977
花落未央
花落未央 2020-11-29 05:36

I have code for reading an url like this:

from urllib2 import Request, urlopen
req = Request(url)
for key, val in headers.items():
    req.add_header(key, va         


        
8条回答
  •  余生分开走
    2020-11-29 05:56

    Had the same issue with socket timeout on the read statement. What worked for me was putting both the urlopen and the read inside a try statement. Hope this helps!

提交回复
热议问题