1

I'm working my way through The Programming Historian 2, a self-tutorial in coding for historians focusing on HTML and Python. I am attempting to complete the lesson Working with Files and Web Pages but am stuck on the Opening URLs with Python unit. I am running the following program:

# open-webpage.py

import urllib2

url = 'http://www.oldbaileyonline.org/print.jsp?div=t17800628-33'

response = urllib2.urlopen(url)
webContent = response.read()

print webContent[0:300]

Every time I run the program Komodo Edit 7 returns the following error message:

Traceback (most recent call last):  
  File "open-webpage.py", line 7, in <module>  
    response = urllib2.urlopen(url)  
  File "C:\Python27\lib\urllib2.py", line 126, in urlopen  
    return _opener.open(url, data, timeout)  
  File "C:\Python27\lib\urllib2.py", line 400, in open  
    response = self._open(req, data)  
  File "C:\Python27\lib\urllib2.py", line 418, in _open  
    '_open', req)  
  File "C:\Python27\lib\urllib2.py", line 378, in _call_chain  
    result = func(*args)  
  File "C:\Python27\lib\urllib2.py", line 1207, in http_open  
    return self.do_open(httplib.HTTPConnection, req)  
  File "C:\Python27\lib\urllib2.py", line 1180, in do_open  
    r = h.getresponse(buffering=True)  
  File "C:\Python27\lib\httplib.py", line 1030, in getresponse  
    response.begin()  
  File "C:\Python27\lib\httplib.py", line 407, in begin  
    version, status, reason = self._read_status()  
  File "C:\Python27\lib\httplib.py", line 365, in _read_status  
    line = self.fp.readline()  
  File "C:\Python27\lib\socket.py", line 447, in readline  
    data = self._sock.recv(self._rbufsize)  
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

I have attempted the program with a number of different urls, always with the same result. The guys at Komodo think the problem is to do with my university's firewall, because I access the internet through my university's proxy. The tech people here told me to change my default browser from RockMelt (chromium) to IE, because only IE is fully supported. I did so with no change and they have no other suggestions.

Can anyone suggest an alternate explanation for the error or a way to address the firewall problem? Thanks.

4

0 回答 0