-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsocks_requests.py
More file actions
38 lines (29 loc) · 880 Bytes
/
socks_requests.py
File metadata and controls
38 lines (29 loc) · 880 Bytes
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
from anyone_protocol_sdk import Socks, Config, Process
# Create a configuration
config = Config(
auto_terms_agreement=True,
display_log=False,
exit_countries=["DE"],
)
# Initialize and start the runner
anon = Process.launch_anon(anonrc_path=config.to_file())
socks = Socks()
try:
# Example GET request
response = socks.get("https://check.en.anyone.tech/api/ip")
print("GET Response:")
print(response.text)
# Example POST request
post_url = "https://httpbin.org/post"
post_data = {"key": "value"}
response = socks.post(post_url, json=post_data)
print("POST Response:")
print(response.json())
# Example DELETE request
response = socks.delete("https://httpbin.org/delete")
print("DELETE Response:")
print(response.json())
except RuntimeError as e:
print(f"Request error: {e}")
finally:
anon.stop()