Python 2.6 & # 8594; Python 3 (ProxyHandler)

I wrote a script that works with proxies (py2.6x):

proxy_support = urllib2.ProxyHandler({'http' : 'http://127.0.0.1:80'}) 

But in py3.11x there is no urllib2 just urllib ... and this does not support ProxyHandler

How can I use a proxy server with urllib? Isn't Python 3 later than Python 2? Why did they uninstall urllib2 in the newer version?

+4
source share
2 answers

In Python 3, urllib2.ProxyHandler now urllib.request.ProxyHandler .

 import urllib.request proxy_support = urllib.request.ProxyHandler({'http' : 'http://127.0.0.1:80'}) 

Many of the old url* libs were merges with the urllib package. Here is a great explanation.

+6
source

He became urllib.request.ProxyHandler .

2to3 can do it for you.

+2
source

Source: https://habr.com/ru/post/1310942/


All Articles