import urllib.request import json import base64 import time creds = base64.b64encode(b"ben:6YGf wVxu gBpz pkqx BGZO lfVP").decode("utf-8") headers = { "Content-Type": "application/json", "Authorization": "Basic " + creds, "User-Agent": "Mozilla/5.0" } def get_js(f): return f"""""" units = [ (235, 0.0321507466), # Grams to Apothecary Ounces (237, 5.0), # Grams to Carats (239, 15.4323584), # Grams to Grains (241, 0.745699872) # Horsepower to Kilowatts ] for eid, f in units: data = json.dumps({'content': get_js(f)}).encode('utf-8') url = f'https://howdoyouconvert.com/wp-json/wp/v2/kadence_element/{eid}' req = urllib.request.Request(url, data=data, headers=headers, method='PUT') try: urllib.request.urlopen(req) print(f"Patched {eid}") except Exception as e: print(f"Error {eid}: {e}") time.sleep(1)