0
votes
from urllib import urlopen
from bs4 import BeautifulSoup
import re

# Copy all of the content from the 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");

for i in range(10):

    for stat in commentary[i].stripped_strings:
        print stat,

    print ""

I am running this python program in eclipse. I have changed my proxy entries in network connections. but i am getting IOError as 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

1
Welcome to Stack Overflow. You can make edits to your question if you want to clarify it or post additional information. For example, please add the traceback to the question instead of in comments. - tripleee
@sumanth: I have not downvoted your question, just made formatting edits to the same. The reason for the down vote may be the question lacking information. - Unni Kris

1 Answers

1
votes

It looks like you have a flakey internet connection. The error "Name or service not known" means the DNS lookup for the page failed, the "Connection timed out error" means you were unable to contact the remote server but the DNS lookup succeeded.