diff --git a/src/proxy.py b/src/proxy.py index 44c44d9..c4aefd8 100644 --- a/src/proxy.py +++ b/src/proxy.py @@ -1,18 +1,23 @@ import requests - +from requests.auth import HTTPProxyAuth def test(proxy): - print(f'http://{proxy.usr}:{proxy.pwd}@{proxy.url}:{proxy.port}') + # print(f'http://{proxy.usr}:{proxy.pwd}@{proxy.url}:{proxy.port}') + + s = requests.Session() + url = "http://example.com" + proxies = { + 'http': f'http://{proxy.url}:{proxy.port}', + 'https': f'http://{proxy.url}:{proxy.port}' + } + auth = HTTPProxyAuth(proxy.usr, proxy.pwd) + + s.proxies = proxies + s.auth = auth try: - r = requests.get( - "http://example.com", - proxies={ - 'http': f'http://{proxy.usr}:{proxy.pwd}@{proxy.url}:{proxy.port}', - 'https': f'http://{proxy.usr}:{proxy.pwd}@{proxy.url}:{proxy.port}' - } - ) + r = s.get(url) if r.status_code == 200: proxy.isworking = True