http - Python urllib2, how to avoid errors - need help -


i using python urllib2 download pages web. not using kind of user_agent etc. getting below sample errors. can tell me easy way avoid them.

http://www.rottentomatoes.com/m/foxy_brown/ server couldn't fulfill request. error code:  403   http://www.spiritus-temporis.com/marc-platt-dancer-/ server couldn't fulfill request. error code:  503  http://www.golf-equipment-guide.com/news/mark-nichols-(golfer).html!! server couldn't fulfill request. error code:  500   http://www.ehx.com/blog/mike-matthews-in-fuzz-documentary!! failed reach server. reason:  timed out incompleteread(5621 bytes read) traceback (most recent call last):     file "download.py", line 43, in <module>     localfile.write(response.read())     file "/usr/lib/python2.6/socket.py", line 327, in read     data = self._sock.recv(rbufsize)     file "/usr/lib/python2.6/httplib.py", line 517, in read     return self._read_chunked(amt)     file "/usr/lib/python2.6/httplib.py", line 563, in _read_chunked     raise incompleteread(value) incompleteread: incompleteread(5621 bytes read) 

thank you
bala

many web resources require kind of cookie or other authentication access, 403 status codes result of this.

503 errors tend mean you're rapidly accessing resources server in loop , need wait briefly before attempting access.

the 500 example doesn't appear exist...

the timeout error may not need "!!", can load resource without it.

i recommend read on http status codes.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -