-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_proxy.py
61 lines (38 loc) · 1.57 KB
/
test_proxy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import requests
# PROXY_ADDR = 'socks5://username:password@localhost:3000'
PROXY_ADDR = 'socks5h://username:[email protected]:3000'
def test_httpbin():
url = 'http://httpbin.org/get'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
print(resp.text)
assert resp.status_code == 200
def test_httpsbin():
url = 'https://httpbin.org/get'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)
def test_httpsgist():
url = 'https://gist.githubusercontent.com/csrgxtu/9c3d4303e262bf5333cc57ff11ea9105/raw/d57dcf1b58d76b5e543618e203f8bffb3fa141d9/gistfile1.txt'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)
def test_httpsgoogle():
url = 'https://www.google.com'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)
def test_httpsbaidu():
url = 'https://baidu.com'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)
def test_httpsyoutube():
url = 'https://youtube.com'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)
def test_httpstwitter():
url = 'https://twitter.com'
resp = requests.get(url, proxies=dict(http=PROXY_ADDR, https=PROXY_ADDR))
assert resp.status_code == 200
print(resp.text)