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" '
54 target_path = "/html/body/div/div/div/div/div/div/table/tr/td"
62 /^A/ && $2 == "CDATA" {
63 update_node_attributes()
68 XmlPayload = substr($0, 2, length($0))
71 XmlPath == target_path && XmlPayload == location {
76 XmlPath == target_path && found {
82 function path_to_string(path, depth, p, i) {
84 for (i = 1; i <= depth; i++) {
90 function update_node( paren, name, key, val, path, attr) {
91 paren = substr($1, 1, 1)
92 name = substr($1, 2, length($1) - 1)
96 XmlPath = path_to_string(_path, _depth)
97 for (key in _hxpipe_curr_attrs) {
98 val = _hxpipe_curr_attrs[key]
99 XmlAttr[XmlPath, key] = val
101 } else if (paren == ")") {
102 delete _hxpipe_curr_attrs
104 for (key in XmlAttr) {
105 split(key, k, SUBSEP)
108 if (path == XmlPath) delete XmlAttr[key]
111 XmlPath = path_to_string(_path, _depth)
113 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
118 function update_node_attributes( key, val, s) {
119 key = substr($1, 2, length($1))
122 sub("^" $1 s $2 s, "", val)
123 _hxpipe_curr_attrs[key] = val
This page took 0.071181 seconds and 4 git commands to generate.