6 # - hxpipe (packaged in html-xml-utils on Debian and Ubuntu)
9 '') location
='New York City:';;
13 curl
'https://health.ny.gov/diseases/communicable/coronavirus/' \
15 |
awk -v location
="$location" '
21 /^A/ && $2 == "CDATA" {
22 update_node_attributes()
27 XmlPayload = substr($0, 2, length($0))
30 XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && XmlPayload == location {
35 XmlPath == "/html/body/div/div/div/div/div/div/table/tr/td" && found {
41 function path_to_string(path, depth, p, i) {
43 for (i = 1; i <= depth; i++) {
49 function update_node( paren, name, key, val, path, attr) {
50 paren = substr($1, 1, 1)
51 name = substr($1, 2, length($1) - 1)
55 XmlPath = path_to_string(_path, _depth)
56 for (key in _hxpipe_curr_attrs) {
57 val = _hxpipe_curr_attrs[key]
58 XmlAttr[XmlPath, key] = val
60 } else if (paren == ")") {
61 delete _hxpipe_curr_attrs
63 for (key in XmlAttr) {
67 if (path == XmlPath) delete XmlAttr[key]
70 XmlPath = path_to_string(_path, _depth)
72 printf("ERROR in input line %d - not a parenthesis: \"%s\"\n", NR, paren) > "/dev/stderr"
77 function update_node_attributes( key, val, s) {
78 key = substr($1, 2, length($1))
81 sub("^" $1 s $2 s, "", val)
82 _hxpipe_curr_attrs[key] = val
This page took 0.083011 seconds and 5 git commands to generate.