c50288cf0e38e9853696bac9cc6fb018414329fe
6 # - hxpipe (packaged in html-xml-utils on Debian and Ubuntu)
20 New York State (Outside of NYC)
29 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 # 2020-03-16 morning-afternoon
55 #target_path = "/html/body/div/div/div/div/div/div/table/tr/td"
57 # 2020-03-16 late evening 22:30
58 target_path = "/html/body/div/div/div/div/div/div/tr/td"
66 /^A/ && $2 == "CDATA" {
67 update_node_attributes()
72 XmlPayload = substr($0, 2, length($0))
75 XmlPath == target_path && XmlPayload == location {
80 XmlPath == target_path && found {
86 function path_to_string(path, depth, p, i) {
88 for (i = 1; i <= depth; i++) {
94 function update_node( paren, name, key, val, path, attr) {
95 paren = substr($1, 1, 1)
96 name = substr($1, 2, length($1) - 1)
100 XmlPath = path_to_string(_path, _depth)
101 for (key in _hxpipe_curr_attrs) {
102 val = _hxpipe_curr_attrs[key]
103 XmlAttr[XmlPath, key] = val
105 } else if (paren == ")") {
106 delete _hxpipe_curr_attrs
108 for (key in XmlAttr) {
109 split(key, k, SUBSEP)
112 if (path == XmlPath) delete XmlAttr[key]
115 XmlPath = path_to_string(_path, _depth)
117 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
122 function update_node_attributes( key, val, s) {
123 key = substr($1, 2, length($1))
126 sub("^" $1 s $2 s, "", val)
127 _hxpipe_curr_attrs[key] = val
This page took 0.076298 seconds and 3 git commands to generate.