I need to use urllib2 with BeautifulSoup. I found the download file for BeautifulSoup and installed it, however, I couldn't find any download files for urllib2, is there another way to intall that module?
Asked
Active
Viewed 6.1k times
1 Answers
11
The module comes with Python, simply import it:
import urllib2
If you're using Python3, the urllib
was replaced by urllib.request. The Urllib PEP (Python3): http://www.python.org/dev/peps/pep-3108/#urllib-package.

dav1d
- 5,917
- 1
- 33
- 52
-
it does not in windows. Only in *nix – karthikr May 16 '13 at 21:36
-
1i used xp. alteast i had to download it. – karthikr May 16 '13 at 21:37
-
Then you either installed Python3 and made a big mistake with getting urllib2 from somewhere in the internet, or you failed hardly to install Python2 correctly. – dav1d May 16 '13 at 21:39
-
If he's using python3, I would hope that installing BeautifulSoup for python2 wouldn't even allow him to import it, though it does make the most sense. Unless of course he installed it manually – Ryan Haining May 16 '13 at 21:40
-
I get an error:import urllib2 Traceback (most recent call last): File "
", line 1, in – Josh May 16 '13 at 22:25import urllib2 ImportError: No module named 'urllib2' -
So instead of import urllib2, import urllib.request? – Josh May 16 '13 at 22:27
-
If you are using Python 3, yes. Also click on the links I posted, they bring you to the documentation. – dav1d May 17 '13 at 12:13
-
On windows (unfortunately), import urllib.request does not work. – Tony Ennis Aug 15 '15 at 13:36
-
@TonyEnnis that has nothing to do with your operating system. You simply have Python 2 installed instead of Python 3. – dav1d Aug 15 '15 at 14:52
-
No I don't. Python 3.5 – Tony Ennis Aug 15 '15 at 23:06