Group updated variable histories
[covid-19-scrapers.git] / fetch-case-count-usa-ny
index 95a039f..e346935 100755 (executable)
@@ -5,9 +5,26 @@
 #     - awk
 #     - hxpipe (packaged in html-xml-utils on Debian and Ubuntu)
 
+# 2020-03-16 morning-afternoon
+#URI='https://health.ny.gov/diseases/communicable/coronavirus/'
+#TARGET_PATH='/html/body/div/div/div/div/div/div/table/tr/td'
+#DEFAULT_LOCATION='New York City:'
+
+# 2020-03-16 late evening 22:30
+#URI='https://health.ny.gov/diseases/communicable/coronavirus/'
+#TARGET_PATH='/html/body/div/div/div/div/div/div/tr/td'
+#DEFAULT_LOCATION='New York City:'
+
+# 2020-03-17 late afternoon 16:35
+URI='https://coronavirus.health.ny.gov/county-county-breakdown-positive-cases'
+TARGET_PATH='/html/body/div/div/main/div/div/div/div/div/div/div/div/table/tbody/tr/td'
+DEFAULT_LOCATION='New York City'
+
 VALID_LOCATIONS='
     Albany
+    Allegany
     Broome
+    Clinton
     Delaware
     Dutchess
     Erie
@@ -16,21 +33,25 @@ VALID_LOCATIONS='
     Monroe
     Montgomery
     Nassau
+    New York City
+    New York State (Outside of NYC)
+    Onondaga
+    Ontario
     Orange
     Putnam
+    Rensselaer
     Rockland
     Saratoga
     Schenectady
     Suffolk
+    Sullivan
     Tioga
     Tompkins
+    Total Positive Cases (Statewide)
     Ulster
     Westchester
-    New York State (Outside of NYC)
-    New York City:
-    Total Positive Cases (Statewide)
+    Wyoming
     '
-DEFAULT_LOCATION='New York City:'
 
 usage() {
         printf "Usage: %s [LOCATION]\n" "$0"
@@ -47,9 +68,12 @@ case "$1" in
      *  ) location="$1";;
 esac
 
-curl 'https://health.ny.gov/diseases/communicable/coronavirus/' \
+curl "$URI" \
 | hxpipe \
-| awk -v location="$location" '
+| awk \
+    -v location="$location" \
+    -v target_path="$TARGET_PATH" \
+    '
     /^[\(\)]/ {
         update_node()
         next
@@ -64,12 +88,12 @@ curl 'https://health.ny.gov/diseases/communicable/coronavirus/' \
         XmlPayload = substr($0, 2, length($0))
     }
 
-    XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && XmlPayload == location {
+    XmlPath == target_path && XmlPayload == location {
         found = 1;
         next
     }
 
-    XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && found {
+    XmlPath == target_path && found {
         print XmlPayload;
         found = 0;
         next;
This page took 0.023528 seconds and 4 git commands to generate.