6 # - hxpipe (packaged in html-xml-utils on Debian and Ubuntu)
29 New York State (Outside of NYC)
31 Total Positive Cases (Statewide)
33 DEFAULT_LOCATION
='New York City:'
36 printf "Usage: %s [LOCATION]\n" "$0"
39 printf '%s\n' "$VALID_LOCATIONS"
40 printf "Default LOCATION:\n %s\n" "$DEFAULT_LOCATION"
46 '' ) location
="$DEFAULT_LOCATION";;
50 curl
'https://health.ny.gov/diseases/communicable/coronavirus/' \
52 |
awk -v location
="$location" '
58 /^A/ && $2 == "CDATA" {
59 update_node_attributes()
64 XmlPayload = substr($0, 2, length($0))
67 XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && XmlPayload == location {
72 XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && found {
78 function path_to_string(path, depth, p, i) {
80 for (i = 1; i <= depth; i++) {
86 function update_node( paren, name, key, val, path, attr) {
87 paren = substr($1, 1, 1)
88 name = substr($1, 2, length($1) - 1)
92 XmlPath = path_to_string(_path, _depth)
93 for (key in _hxpipe_curr_attrs) {
94 val = _hxpipe_curr_attrs[key]
95 XmlAttr[XmlPath, key] = val
97 } else if (paren == ")") {
98 delete _hxpipe_curr_attrs
100 for (key in XmlAttr) {
101 split(key, k, SUBSEP)
104 if (path == XmlPath) delete XmlAttr[key]
107 XmlPath = path_to_string(_path, _depth)
109 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
114 function update_node_attributes( key, val, s) {
115 key = substr($1, 2, length($1))
118 sub("^" $1 s $2 s, "", val)
119 _hxpipe_curr_attrs[key] = val
This page took 0.053882 seconds and 4 git commands to generate.