I have the following simple code:
import urllib2
import sys
sys.path.append('../BeautifulSoup/BeautifulSoup-3.1.0.1')
from BeautifulSoup import *
page='http://en.wikipedia.org/wiki/Main_Page'
c=urllib2.urlopen(page)
This code generates the following error messages:
c=urllib2.urlopen(page)File "/usr/lib64/python2.4/urllib2.py", line 130, in urlopenreturn _opener.open(url, data)File "/usr/lib64/python2.4/urllib2.py", line 364, in openresponse = meth(req, response)File "/usr/lib64/python2.4/urllib2.py", line 471, in http_responseresponse = self.parent.error(File "/usr/lib64/python2.4/urllib2.py", line 402, in errorreturn self._call_chain(*args)File "/usr/lib64/python2.4/urllib2.py", line 337, in _call_chainresult = func(*args)File "/usr/lib64/python2.4/urllib2.py", line 480, in http_error_defaultraise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
But if I replace urllib2 by urllib, I get no error messages. Can anybody explain this behavior?