6 # - hxpipe (packaged in html-xml-utils on Debian and Ubuntu)
8 # 2020-03-16 morning-afternoon
9 #URI='https://health.ny.gov/diseases/communicable/coronavirus/'
10 #TARGET_PATH='/html/body/div/div/div/div/div/div/table/tr/td'
11 #DEFAULT_LOCATION='New York City:'
13 # 2020-03-16 late evening 22:30
14 #URI='https://health.ny.gov/diseases/communicable/coronavirus/'
15 #TARGET_PATH='/html/body/div/div/div/div/div/div/tr/td'
16 #DEFAULT_LOCATION='New York City:'
18 # 2020-03-17 late afternoon 16:35
19 URI
='https://coronavirus.health.ny.gov/county-county-breakdown-positive-cases'
20 TARGET_PATH
='/html/body/div/div/main/div/div/div/div/div/div/div/div/table/tbody/tr/td'
21 DEFAULT_LOCATION
='New York City'
37 New York State (Outside of NYC)
50 Total Positive Cases (Statewide)
57 printf "Usage: %s [LOCATION]\n" "$0"
60 printf '%s\n' "$VALID_LOCATIONS"
61 printf "Default LOCATION:\n %s\n" "$DEFAULT_LOCATION"
67 '' ) location
="$DEFAULT_LOCATION";;
74 -v location
="$location" \
75 -v target_path
="$TARGET_PATH" \
82 /^A/ && $2 == "CDATA" {
83 update_node_attributes()
88 XmlPayload = substr($0, 2, length($0))
91 XmlPath == target_path && XmlPayload == location {
96 XmlPath == target_path && found {
102 function path_to_string(path, depth, p, i) {
104 for (i = 1; i <= depth; i++) {
110 function update_node( paren, name, key, val, path, attr) {
111 paren = substr($1, 1, 1)
112 name = substr($1, 2, length($1) - 1)
116 XmlPath = path_to_string(_path, _depth)
117 for (key in _hxpipe_curr_attrs) {
118 val = _hxpipe_curr_attrs[key]
119 XmlAttr[XmlPath, key] = val
121 } else if (paren == ")") {
122 delete _hxpipe_curr_attrs
124 for (key in XmlAttr) {
125 split(key, k, SUBSEP)
128 if (path == XmlPath) delete XmlAttr[key]
131 XmlPath = path_to_string(_path, _depth)
133 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
138 function update_node_attributes( key, val, s) {
139 key = substr($1, 2, length($1))
142 sub("^" $1 s $2 s, "", val)
143 _hxpipe_curr_attrs[key] = val
This page took 0.080015 seconds and 4 git commands to generate.