Working proxy test
This commit is contained in:
parent
e6952a8025
commit
1f655deeb8
23
src/proxy.py
23
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
|
||||
|
|
Loading…
Reference in New Issue