Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I am executing the below code:

from bs4 import BeautifulSoup

import urllib2

url = 'http://www.thefamouspeople.com/singers.php'

html = urllib2.urlopen(url)

soup = BeautifulSoup(html)

But I got to know that I have to install the urllib3 package.

Any information or example??

P/S: I'm using python 3.4.

1 Answer

0 votes
by (108k points)

Please be informed that the urllib3 is a separate library from urllib and urllib2. It has lots of new highlights to the urllibs in the standard library, if you want them, things like re-using connections. 

If you want to work with urllib3, you'll need to install it through pip install urllib3. A basic example looks like this:

from bs4 import BeautifulSoup

import urllib3

http = urllib3.PoolManager()

url = 'http://www.thefamouspeople.com/singers.php'

response = http.request('GET', url)

soup = BeautifulSoup(response.data)

If you are a beginner and want to know more about Python then do refer to the python online course that will help you out in a better way. 

Related questions

0 votes
1 answer
asked Oct 29, 2019 in Python by humble gumble (19.4k points)
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Browse Categories

...