python - IO Error while scrapping web -


from urllib import urlopen bs4 import beautifulsoup import re  # copy of content provided web page webpage = urlopen('http://stats.espncricinfo.com/indian-premier-league-2012/engine/records/averages/batting.html?id=6680;type=tournament').read()  soup=beautifulsoup(webpage);  commentary=soup.find_all("tr", "data2");  in range(10):      stat in commentary[i].stripped_strings:         print stat,      print "" 

i running python program in eclipse. have changed proxy entries in network connections. getting ioerror below :

ioerror: [errno socket error] [errno -2] name or service not known

traceback (most recent call last):

file "/home/sumanth/workspace/python/scraping.py", line 22, in webpage = urlopen('http://stats.espncricinfo.com/indian-premier-league-2012/engine/records/averages/batting.html?id=6680;type=tournament').read()

file "/usr/lib/python2.7/urllib.py", line 86, in urlopen return opener.open(url)

file "/usr/lib/python2.7/urllib.py", line 207, in open return getattr(self, name)(url)

file "/usr/lib/python2.7/urllib.py", line 344, in open_http h.endheaders(data)

file "/usr/lib/python2.7/httplib.py", line 958, in endheaders self._send_output(message_body)

file "/usr/lib/python2.7/httplib.py", line 818, in _send_output self.send(msg)

file "/usr/lib/python2.7/httplib.py", line 780, in send self.connect()

file "/usr/lib/python2.7/httplib.py", line 761, in connect self.timeout, self.source_address)

file "/usr/lib/python2.7/socket.py", line 571, in create_connection raise err

ioerror: [errno socket error] [errno 110] connection timed out

it looks have flakey internet connection. error "name or service not known" means dns lookup page failed, "connection timed out error" means unable contact remote server dns lookup succeeded.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -