[Tutor] reading web page with BeautifulSoup
Ed Owens
eowens0124 at gmx.com
Thu Dec 13 02:47:58 CET 2012
>>> from urllib2 import urlopen
>>> page = urlopen('w1.weather.gov/obhistory/KDCA.html')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 126, in urlopen
return _opener.open(url, data, timeout)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 386, in open
protocol = req.get_type()
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 248, in get_type
raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: w1.weather.gov/obhistory/KDCA.html
>>>
Can anyone see what I'm doing wrong here? I have bs4 and urllib2
imported, and get the above error when trying to read that page. I can
copy the url from the error message into my browser and get the page.
Ed
More information about the Tutor
mailing list