FlorianREGAZ / Python-Tls-Client

Advanced HTTP Library
MIT License
660 stars 136 forks source link

Proxy wont work #26

Closed 0xAndrei closed 1 year ago

0xAndrei commented 1 year ago

Hello, Im trying to utilise proxies with this tls-client but whenever i make a request to some website im using my machine ip instead of the proxy

thats my code:

import tls_client session = tls_client.Session(client_identifier="chrome_105") test = session.get("http://api.ipify.org/?format=json", proxy="http://xxx:xxx@geo.iproyal.com:12321") print(test.json())

fnk93 commented 1 year ago

@0xAndrei That's an issue of the shared library. Proxy will only be set on https:// requests. Try running this (https instead of http):

resp = session.get('https://api.ipify.org/?format=json', proxy="http://xxx:xxx@geo.iproyal.com:12321/")
print(resp.json())

For me this results in the following:

raw request bytes sent over wire: 154 (0 kb)
cookies on request: []
requested https://api.ipify.org/?format=json : status 200
raw response bytes received over wire: 174 (0 kb)
{'ip': '185.217.137.216'}
0xAndrei commented 1 year ago

@0xAndrei That's an issue of the shared library. Proxy will only be set on https:// requests. Try running this (https instead of http):

resp = session.get('https://api.ipify.org/?format=json', proxy="http://xxx:xxx@geo.iproyal.com:12321/")
print(resp.json())

For me this results in the following:

raw request bytes sent over wire: 154 (0 kb)
cookies on request: []
requested https://api.ipify.org/?format=json : status 200
raw response bytes received over wire: 174 (0 kb)
{'ip': '185.217.137.216'}

Oh im actually dumb, I forgot that i had to use https. It works thank you!