X-Git-Url: https://git.xandkar.net/?p=covid-19-scrapers.git;a=blobdiff_plain;f=fetch-case-count-usa-ny;h=808d7be4b60acebcae2c0bf2a1d789ef8dfe0287;hp=95a039f1f12a9909288c28c721a5f4d05cc026b7;hb=2162fd84b7bf9f87e6318e139e9f2a687659e26e;hpb=0b60ba947fe0490f018137cbb9c51b01bdcb8b39 diff --git a/fetch-case-count-usa-ny b/fetch-case-count-usa-ny index 95a039f..808d7be 100755 --- a/fetch-case-count-usa-ny +++ b/fetch-case-count-usa-ny @@ -7,7 +7,9 @@ VALID_LOCATIONS=' Albany + Allegany Broome + Clinton Delaware Dutchess Erie @@ -16,21 +18,26 @@ 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:' +DEFAULT_LOCATION='New York City' usage() { printf "Usage: %s [LOCATION]\n" "$0" @@ -47,9 +54,26 @@ case "$1" in * ) location="$1";; esac -curl 'https://health.ny.gov/diseases/communicable/coronavirus/' \ +# 2020-03-16 +#URI='https://health.ny.gov/diseases/communicable/coronavirus/' + +# 2020-03-17 +URI='https://coronavirus.health.ny.gov/county-county-breakdown-positive-cases' + +curl "$URI" \ | hxpipe \ | awk -v location="$location" ' + BEGIN { + # 2020-03-16 morning-afternoon + #target_path = "/html/body/div/div/div/div/div/div/table/tr/td" + + # 2020-03-16 late evening 22:30 + #target_path = "/html/body/div/div/div/div/div/div/tr/td" + + # 2020-03-17 late afternoon 16:35 + target_path = "/html/body/div/div/main/div/div/div/div/div/div/div/div/table/tbody/tr/td" + } + /^[\(\)]/ { 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;