Python – urllib module error! AttributeError: ‘module’ object has no attribute ‘request’

pythonpython-2.7

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.

Best Answer

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

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

Related Topic