-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestExample4.awk
More file actions
35 lines (26 loc) · 719 Bytes
/
Copy pathrestExample4.awk
File metadata and controls
35 lines (26 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
BEGIN {
# These can also be specified on the command line.
IT = "rest";
FS = "[\t]";
# Put everything in DEFPROPS:
DEFPROPS["restQuery"] = "/_json/bpi/*|/_json/time/updated";
DEFPROPS["restIndent"] = 1;
DEFPROPS["httpUrl"] = "http://api.coindesk.com/v1/bpi/currentprice.json";
DEFPROPS["httpHeader.Accept"] = "application/json";
print "Bitcoin prices:";
}
# Check for invalid response code
isXmlNulNode(_$NODE) {
print getXmlNodeValue(_$NODE);
exit;
}
/^updated$/ {
node = getXmlNode(_$NODE, "text()");
print $0, "=", getXmlNodeValue(node);
next;
}
# else
{
node = getXmlNode(_$NODE, "./rate/text()");
print $0, getXmlNodeValue(node);
}