20 lines
600 B
Python
20 lines
600 B
Python
import urllib.request
|
|
import json
|
|
import base64
|
|
|
|
url_base = "https://howdoyouconvert.com/wp-json/wp/v2/calculator/107?context=edit"
|
|
creds = base64.b64encode(b"ben:6YGf wVxu gBpz pkqx BGZO lfVP").decode("utf-8")
|
|
headers = {
|
|
"Authorization": "Basic " + creds,
|
|
"User-Agent": "Mozilla/5.0"
|
|
}
|
|
|
|
req = urllib.request.Request(url_base, headers=headers)
|
|
try:
|
|
resp = urllib.request.urlopen(req)
|
|
data = json.loads(resp.read().decode("utf-8"))
|
|
print(data['content']['raw'])
|
|
except Exception as e:
|
|
print("Error:", e)
|
|
if hasattr(e, 'read'): print("Response:", e.read().decode("utf-8"))
|