I've searched through the forums to try and figure out why the following code was not working:
import nltk, re, pprint
from urllib import request
url = "http://www.gutenberg.org/files/2554/2554.txt"
response = request.urlopen(url)
raw = response.read().decode('utf8')
print(raw[:75])
But have thus far been unsuccessful in resolving things. Here are some similar solutions I tried to implement to no avail: Forum 1, Forum 2
The error I get is:
File "C:\Python33\lib\urllib\request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "C:\Python33\lib\urllib\request.py", line 472, in open
response = meth(req, response)
File "C:\Python33\lib\urllib\request.py", line 582, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python33\lib\urllib\request.py", line 510, in error
return self._call_chain(*args)
File "C:\Python33\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "C:\Python33\lib\urllib\request.py", line 590, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
Any help would be greatly appreciated