diff --git a/httpoll.py b/httpoll.py index a95bb90..bafd480 100755 --- a/httpoll.py +++ b/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()