cleaned up the proxy situation
All checks were successful
Python Lint & Test / build (push) Successful in 11s
All checks were successful
Python Lint & Test / build (push) Successful in 11s
This commit is contained in:
parent
a6ae230f8e
commit
74650baf5d
19
httpoll.py
19
httpoll.py
@ -2,17 +2,13 @@
|
||||
|
||||
import argparse
|
||||
import requests
|
||||
import urllib3
|
||||
from time import time, sleep
|
||||
|
||||
import urllib3
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
no_proxy = {
|
||||
# no proxy
|
||||
'no': 'pass',
|
||||
}
|
||||
|
||||
args = {}
|
||||
args = dict()
|
||||
proxy = None
|
||||
|
||||
|
||||
def poll():
|
||||
@ -21,7 +17,7 @@ def poll():
|
||||
status, result = "", ""
|
||||
try:
|
||||
r = requests.get(url=args.URL, timeout=10.0,
|
||||
verify=False, proxies=no_proxy)
|
||||
verify=False, proxies=proxy)
|
||||
status = "ok"
|
||||
result = str(r)
|
||||
except requests.exceptions.RequestException as e:
|
||||
@ -47,12 +43,11 @@ if __name__ == "__main__":
|
||||
try:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('URL')
|
||||
parser.add_argument('--use-proxy')
|
||||
parser.add_argument('-p')
|
||||
parser.add_argument('--no-proxy', action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.use_proxy or args.p:
|
||||
no_proxy = None
|
||||
if args.no_proxy:
|
||||
proxy = {'no': 'pass'}
|
||||
|
||||
run()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user