Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

urllib module error! AttributeError: 'module' object has no attribute 'request'

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.

like image 805
Manas Chaturvedi Avatar asked Nov 01 '13 15:11

Manas Chaturvedi


1 Answers

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

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

like image 105
falsetru Avatar answered Nov 20 '22 18:11

falsetru