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'
55 printf "Usage: %s [OPTION | LOCATION]\n" "$0"
57 printf 'OPTION = -h | --all \n'
59 printf '%s\n' "$VALID_LOCATIONS"
60 printf "Default LOCATION:\n %s\n" "$DEFAULT_LOCATION"
67 '' ) target_location
="$DEFAULT_LOCATION";;
68 * ) target_location
="$1";;
74 -v target_location
="$target_location" \
75 -v target_path
="$TARGET_PATH" \
76 -v opt_all
="$opt_all" \
83 /^A/ && $2 == "CDATA" {
84 update_node_attributes()
89 XmlPayload = substr($0, 2, length($0))
92 XmlPath == target_path && !location {
93 location = XmlPayload;
97 XmlPath == target_path && location {
98 case_counts[location] = XmlPayload;
105 for (location in case_counts)
106 printf("%d|%s\n", case_counts[location], location)
108 printf("%d\n", case_counts[target_location])
112 function path_to_string(path, depth, p, i) {
114 for (i = 1; i <= depth; i++) {
120 function update_node( paren, name, key, val, path, attr) {
121 paren = substr($1, 1, 1)
122 name = substr($1, 2, length($1) - 1)
126 XmlPath = path_to_string(_path, _depth)
127 for (key in _hxpipe_curr_attrs) {
128 val = _hxpipe_curr_attrs[key]
129 XmlAttr[XmlPath, key] = val
131 } else if (paren == ")") {
132 delete _hxpipe_curr_attrs
134 for (key in XmlAttr) {
135 split(key, k, SUBSEP)
138 if (path == XmlPath) delete XmlAttr[key]
141 XmlPath = path_to_string(_path, _depth)
143 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
148 function update_node_attributes( key, val, s) {
149 key = substr($1, 2, length($1))
152 sub("^" $1 s $2 s, "", val)
153 _hxpipe_curr_attrs[key] = val
This page took 0.067888 seconds and 5 git commands to generate.