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