8

I was currently playing with the 'urllib' module in python, and tried this to extract source code of a website:

import urllib
temp = urllib.request.urlopen('https://www.quora.com/#')

However, I get the following error:

Traceback (most recent call last): File "", line 1, in temp = urllib.request.urlopen('https://www.quora.com/#') AttributeError: 'module' object has no attribute 'request'

I am using Python 2.7.5 by the way.

3
  • Where is the documentation telling you about "urllib.request.urlopen"? Commented Nov 1, 2013 at 15:32
  • docs.python.org/3.3/howto/urllib2.html Commented Nov 1, 2013 at 15:37
  • Python 3 documentation = Python 2 documentation? Think about it Commented Nov 1, 2013 at 15:49

1 Answer 1

15

It seems like you are reading Python 3.x documentation.

It's urllib.urlopen in Python 2.x.

Sign up to request clarification or add additional context in comments.

1 Comment

Yup, works now! Was indeed reading the wrong documentation afterall.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.