-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (23 loc) · 1.03 KB
/
main.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
import requests
from proxy_spinner.proxy_spinner import ProxySpinner
if __name__ == '__main__':
# Get my location:
get_location_url = "https://cmp.inmobi.com/geoip"
# Without proxy
response = requests.get(get_location_url, timeout=10).json()
print(f"Without Proxy: {response['city']} ({response['country']})")
# Get a proxy
proxy_spinner = ProxySpinner()
proxy = proxy_spinner.renew_proxy(verbose=True)
# With proxy
with proxy_spinner:
response = requests.get(get_location_url, timeout=10).json()
print(f"With Proxy: {response['city']} ({response['country']}) [Proxy: {proxy}]")
# Without proxy
response = requests.get(get_location_url, timeout=10).json()
print(f"Without Proxy: {response['city']} ({response['country']})")
proxy = proxy_spinner.renew_proxy(verbose=True)
# With proxy
with proxy_spinner:
response = requests.get(get_location_url, timeout=10).json()
print(f"With New Proxy: {response['city']} ({response['country']}) [Proxy: {proxy}]")