UA header for BIN APIs
This commit is contained in:
4
app.py
4
app.py
@@ -21,7 +21,9 @@ def db():
|
|||||||
return con
|
return con
|
||||||
|
|
||||||
def http(url, headers=None, data=None, method="GET", timeout=12):
|
def http(url, headers=None, data=None, method="GET", timeout=12):
|
||||||
req = urllib.request.Request(url, headers=headers or {}, data=data, method=method)
|
h = {"User-Agent": "Mozilla/5.0 (Auriga toolbox)"}
|
||||||
|
h.update(headers or {})
|
||||||
|
req = urllib.request.Request(url, headers=h, data=data, method=method)
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(req, timeout=timeout) as r:
|
with urllib.request.urlopen(req, timeout=timeout) as r:
|
||||||
return r.status, r.read().decode("utf-8", "replace")
|
return r.status, r.read().decode("utf-8", "replace")
|
||||||
|
|||||||
Reference in New Issue
Block a user