feat: Add new calculator batches (6-10) and associated deployment/verification scripts, and update the calculator list.
This commit is contained in:
46
verify_batch_10.py
Normal file
46
verify_batch_10.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import urllib.request
|
||||
import json
|
||||
import re
|
||||
|
||||
batch_10_results = [
|
||||
{"url": "https://howdoyouconvert.com/calculator/megabytes-to-gigabytes/?ao_noptimize=1", "v1": 1000, "expected_v2": 1, "m": 0.001},
|
||||
{"url": "https://howdoyouconvert.com/calculator/megajoules-to-kilowatt-hours/?ao_noptimize=1", "v1": 3.6, "expected_v2": 1, "m": 0.277778},
|
||||
{"url": "https://howdoyouconvert.com/calculator/meters-to-feet/?ao_noptimize=1", "v1": 1, "expected_v2": 3.28084, "m": 3.28084},
|
||||
{"url": "https://howdoyouconvert.com/calculator/meters-to-yards/?ao_noptimize=1", "v1": 1, "expected_v2": 1.09361, "m": 1.09361},
|
||||
{"url": "https://howdoyouconvert.com/calculator/metric-tons-to-short-tons/?ao_noptimize=1", "v1": 1, "expected_v2": 1.10231, "m": 1.10231},
|
||||
{"url": "https://howdoyouconvert.com/calculator/minutes-to-hours/?ao_noptimize=1", "v1": 60, "expected_v2": 1, "m": 0.0166667},
|
||||
{"url": "https://howdoyouconvert.com/calculator/minutes-to-seconds/?ao_noptimize=1", "v1": 1, "expected_v2": 60, "m": 60.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/nautical-miles-to-kilometers/?ao_noptimize=1", "v1": 1, "expected_v2": 1.852, "m": 1.852},
|
||||
{"url": "https://howdoyouconvert.com/calculator/newtons-to-dynes/?ao_noptimize=1", "v1": 1, "expected_v2": 100000.0, "m": 100000.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/ounces-to-grams/?ao_noptimize=1", "v1": 1, "expected_v2": 28.3495, "m": 28.3495}
|
||||
]
|
||||
|
||||
headers = {"User-Agent": "Mozilla/5.0"}
|
||||
|
||||
for calc in batch_10_results:
|
||||
print(f"\n--- Verifying {calc['url']} ---")
|
||||
req = urllib.request.Request(calc['url'], headers=headers)
|
||||
try:
|
||||
resp = urllib.request.urlopen(req, timeout=30).read().decode("utf-8")
|
||||
|
||||
if "initRetries" in resp and "setTimeout(init, 100)" in resp:
|
||||
print("Robust JS: OK")
|
||||
else:
|
||||
print("Robust JS: MISSING")
|
||||
|
||||
m_pattern = r'i2\.value = parseFloat\(\(v \* ([\d\.e\-]+)\)'
|
||||
m = re.search(m_pattern, resp)
|
||||
if m:
|
||||
actual_m = float(m.group(1))
|
||||
print(f"Multiplier: {actual_m} (Expected {calc['m']})")
|
||||
if abs(actual_m - calc['m']) / (calc['m'] or 1) < 0.0001:
|
||||
print("Math Match: OK")
|
||||
else:
|
||||
print("Math Match: FAIL")
|
||||
else:
|
||||
print("Multiplier: NOT FOUND")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
print("\nVERIFICATION COMPLETE")
|
||||
Reference in New Issue
Block a user