scraper tutorial error message

A forum for general discussion of the Python programming language.

scraper tutorial error message

Postby AEA » Fri May 17, 2013 2:03 am

I am following a tutorial for web scraping, and I have been stopped very early on, I am using version 3.3. I am trying to run the code:

Code: Select all
import urllib

htmlfile = urllib.urlopen("")

htmltext =

print (htmltext)

and it is returning the error message :
Code: Select all
Traceback (most recent call last):
  File "C:/Program Files (x86)/Notepad++/", line 3, in <module>
    htmlfile = urllib.urlopen("")
AttributeError: 'module' object has no attribute 'urlopen'

Any ideas? I am sure this is a stupid question, but I am a complete novice.

Many thanks
Posts: 32
Joined: Thu Apr 18, 2013 11:37 am

Re: scraper tutorial error message

Postby metulburr » Fri May 17, 2013 2:22 am

its urllib.request.urlopen() in python3.x. And just for some extra info, the same in python2.x is urllib2.urlopen().
You have to be careful when using tutorials as most are written in 2.x and using 3.x modules have moved or renamed.
Code: Select all
import urllib.request

htmlfile = urllib.request.urlopen("")

htmltext =

print (htmltext)
we will be moving to on October 1 2016
more details here
User avatar
Posts: 2244
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 5 guests