Skip to main content

Tweak the interface slightly

ID
fd35132
date
2022-11-15 20:23:00+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
5320614
message
Tweak the interface slightly
changed files
1 file, 10 additions, 12 deletions

Changed files

measure.py (1349) → measure.py (1035)

diff --git a/measure.py b/measure.py
index 289c22d..9e8559d 100755
--- a/measure.py
+++ b/measure.py
@@ -2,6 +2,7 @@
 
 import json
 import os
+import sys
 import urllib.request
 
 
@@ -22,21 +23,18 @@ def analyse(*, url, name):
     with open(f'_out/{name}.json', 'w') as outfile:
         outfile.write(json.dumps(json.loads(next_data), indent=2, sort_keys=True))
 
-    print(url, name)
     print(f"html      = {naturalsize(len(html))}")
     print(f"next_data = {naturalsize(len(next_data)).rjust(9)} ({int(len(next_data) / len(html) * 100)}%)")
     print("")
+    print(f"Saved HTML to _out/{name}.html")
+    print(f"Saved JSON to _out/{name}.json")
 
 
 if __name__ == "__main__":
-    for url, name in [
-        ("https://wellcomecollection.org/", "homepage"),
-        ("https://wellcomecollection.org/stories", "stories"),
-        ("https://wellcomecollection.org/articles/Yp3GthEAACIAwRi9", "article"),
-        # ("http://localhost:3000/whats-on", "whats-on"),
-        # ("http://localhost:3000/works", "works"),
-        # ("http://localhost:3000/images", "images"),
-        # ("http://localhost:3000/works/a222wwjt", "a222wwjt"),
-        # ("http://localhost:3000/works?query=fish", "search-fish"),
-    ]:
-        analyse(url=url, name=name)
+    try:
+        url = sys.argv[1]
+        name = sys.argv[2]
+    except IndexError:
+        sys.exit(f"Usage: {__file__} <URL> <NAME>")
+
+    analyse(url=url, name=name)