From 74650baf5dfaf3dc32863026c26cb31373a4fec4 Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer Date: Wed, 15 Nov 2023 19:05:04 +0100 Subject: [PATCH] cleaned up the proxy situation --- httpoll.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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()