[Tutor] web scraping using Python and urlopen in Python 3.3

Seema V Srivastava seema.var at gmail.com
Wed Nov 7 16:44:37 CET 2012


Hi,
I am new to Python, trying to learn it by carrying out specific tasks.  I
want to start with trying to scrap the contents of a web page.  I have
downloaded Python 3.3 and BeautifulSoup 4.

If I call upon urlopen in any form, such as below, I get the error as shown
below the syntax:  Does urlopen not apply to Python 3.3?  If not then
what;s the syntax I should be using?  Thanks so much.

import urllib
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib.urlopen("http://www.pinterest.com"))

Traceback (most recent call last):
  File "C:\Users\Seema\workspace\example\main.py", line 3, in <module>
    soup = BeautifulSoup(urllib.urlopen("http://www.pinterest.com"))
AttributeError: 'module' object has no attribute 'urlopen'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121107/74fc0ad7/attachment.html>


More information about the Tutor mailing list