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 argparse
|
||||||
import requests
|
import requests
|
||||||
|
import urllib3
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
|
|
||||||
import urllib3
|
|
||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
no_proxy = {
|
args = dict()
|
||||||
# no proxy
|
proxy = None
|
||||||
'no': 'pass',
|
|
||||||
}
|
|
||||||
|
|
||||||
args = {}
|
|
||||||
|
|
||||||
|
|
||||||
def poll():
|
def poll():
|
||||||
@ -21,7 +17,7 @@ def poll():
|
|||||||
status, result = "", ""
|
status, result = "", ""
|
||||||
try:
|
try:
|
||||||
r = requests.get(url=args.URL, timeout=10.0,
|
r = requests.get(url=args.URL, timeout=10.0,
|
||||||
verify=False, proxies=no_proxy)
|
verify=False, proxies=proxy)
|
||||||
status = "ok"
|
status = "ok"
|
||||||
result = str(r)
|
result = str(r)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
@ -47,12 +43,11 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('URL')
|
parser.add_argument('URL')
|
||||||
parser.add_argument('--use-proxy')
|
parser.add_argument('--no-proxy', action="store_true")
|
||||||
parser.add_argument('-p')
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.use_proxy or args.p:
|
if args.no_proxy:
|
||||||
no_proxy = None
|
proxy = {'no': 'pass'}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user