I am using Python 3.2. I can import "urllib" library just like with 2.x version. But I can't find methods such as urlopen, urlretrieve, etc. What gives? How do I retrieve a webpage on v3.2?
I have tried to import urllib2 and urllib3 libraries. But my machine says it can't find those modules so not importable. Why these two newest libraries aren't supported in v3.2?
You should use urllib.request
. Example here.
The 2.x docs mention that in Python 3.x, the modules have been split into urllib.request
and urllib.error
. If you have some Python 2.x code and want to convert the modules to 3.x, you may be able to use the 2to3
tool.
It was changed in the newer versions and was split up to now be urllib.request
.
from urllib.request import urlopen
A lot of what you're looking for is in the python library section on urllib.request and someone just mentioned an actual example from the documents that shows how the urllib.request.urlopen can be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With