-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
50 lines (40 loc) · 1.36 KB
/
demo.py
File metadata and controls
50 lines (40 loc) · 1.36 KB
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
from request_middleware.request import Request
URL = "http://localhost:5555/{}"
def request_api():
req = Request("key", "test_api", cache=False)
key = req.get_key_proxy()
headers = {"key": key}
for i in range(5):
response = req.send("GET", URL.format("api"),
headers=headers, data={"dummy": "data"}).json()
req.close_session()
req = Request("key", "test_api", cache=False)
key2 = req.get_key_proxy()
headers = {"key": key2}
for i in range(5):
response = req.send("GET", URL.format("api"),
headers=headers, data={"dummy": "data"}).json()
req.close_session()
def request_proxy():
req = Request("ip", "test_proxy", cache=False)
ip = req.get_key_proxy()
req.add_user_agent()
proxies = {
"http": "http://" + ip,
"https": "https://" + ip
}
response = req.send("POST", URL.format("proxy"),
proxies=proxies, data={"dummy": "data"})
response = response.json()
ip2 = req.get_key_proxy()
req.add_user_agent()
proxies = {
"http": "http://" + ip,
"https": "https://" + ip
}
response = req.send("POST", URL.format("proxy"),
proxies=proxies, data={"dummy": "data"}).json()
req.close_session()
if __name__ == "__main__":
request_api()
request_proxy()