Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using urllib2 for Python3 [closed]

Tags:

python

web

I wanted to use urllib2 for python 3, but I don't think it's available in such name.

I use urllib.request, is there another way to use urllib2?

like image 264
Josh Avatar asked Oct 15 '25 15:10

Josh


1 Answers

urllib2 in Python 3 has been split into several modules:

The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

urllib.request is what you want to use for issuing HTTP requests.

Alternatively, the open source Requests library provides a simpler and cleaner API for making HTTP requests in both Python 2 and 3.

like image 177
Xion Avatar answered Oct 18 '25 05:10

Xion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!