feat: Add new calculator batches (6-10) and associated deployment/verification scripts, and update the calculator list.
This commit is contained in:
49
verify_batch_8.py
Normal file
49
verify_batch_8.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import urllib.request
|
||||
import json
|
||||
import re
|
||||
|
||||
batch_8_results = [
|
||||
{"url": "https://howdoyouconvert.com/calculator/grams-to-micrograms/?ao_noptimize=1", "v1": 1, "expected_v2": 1000000, "m": 1000000.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/grams-to-milligrams/?ao_noptimize=1", "v1": 1, "expected_v2": 1000, "m": 1000.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/hectopascals-to-pascals/?ao_noptimize=1", "v1": 1, "expected_v2": 100, "m": 100.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/hectopascals-to-millibars/?ao_noptimize=1", "v1": 1, "expected_v2": 1, "m": 1.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/joules-to-kilojoules/?ao_noptimize=1", "v1": 1000, "expected_v2": 1, "m": 0.001},
|
||||
{"url": "https://howdoyouconvert.com/calculator/kilojoules-to-joules/?ao_noptimize=1", "v1": 1, "expected_v2": 1000, "m": 1000.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/micrograms-to-grams/?ao_noptimize=1", "v1": 1000000, "expected_v2": 1, "m": 0.000001},
|
||||
{"url": "https://howdoyouconvert.com/calculator/milligrams-to-grams/?ao_noptimize=1", "v1": 1000, "expected_v2": 1, "m": 0.001},
|
||||
{"url": "https://howdoyouconvert.com/calculator/millibars-to-pascals/?ao_noptimize=1", "v1": 1, "expected_v2": 100, "m": 100.0},
|
||||
{"url": "https://howdoyouconvert.com/calculator/millimeters-of-mercury-to-pascals/?ao_noptimize=1", "v1": 1, "expected_v2": 133.322, "m": 133.322}
|
||||
]
|
||||
|
||||
headers = {"User-Agent": "Mozilla/5.0"}
|
||||
|
||||
for calc in batch_8_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")
|
||||
|
||||
# Check for robust JS
|
||||
if "initRetries" in resp and "setTimeout(init, 100)" in resp:
|
||||
print("Robust JS: OK")
|
||||
else:
|
||||
print("Robust JS: MISSING")
|
||||
|
||||
# Extract multiplier (using flexible regex for scientific notation if needed, but here they are standard)
|
||||
# Match v * factor. The factor might be 1e-06
|
||||
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.000001:
|
||||
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