I want to use socks5 proxy in my code. How to do this?
My code:
from urllib.request import Request, urlopen
url = "https://api.ipify.org/"
request = Request(url)
response = urlopen(request)
print(response.read())
In addition I can say that with http/https proxies
I did:
request.set_proxy(proxy_address, "http")
before
response = urlopen(url)
, but now it doesn't work.
EDIT
I found sth like that
from urllib.request import Request, urlopen
import socks
import socket
request = Request("https://api.ipify.org/")
socks.set_default_proxy(socks.SOCKS5, IP_ADDR, PORT)
socket.socket = socks.socksocket
response = urlopen(request)
print(response.read())
But it gives me
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain