Code:
#! /usr/bin/gawk -f
BEGIN{ startF=0; startD=0; descS=0; statS=0 }
/checked/ && /updateUnits/ {
gsub(/[[:cntrl:]]/,"")
match($0, /value..([a-zA-Z]+)/, test)
if (test[1] == "celsius")
uniT="°C"
else
uniT="°F"
}
/feed-tabs/ {
if (startF) startF=0; else startF=1;
}
/detail-tab-panel/ {
if (startD) startD=0; else startD=1;
}
startD != 0 && /desc/ {
if (descS) descS=0; else descS=1;
}
startD != 0 && descS == 0 && /stat/ {
if (statS) statS=0; else statS=1;
}
startF != 0 && /h3/ {
match($0, /.*>([[:alpha:]]+)<.*/, test)
string=(string "feed|" test[1])
}
startF != 0 && /h4/ {
match($0, /.*>([[:print:]]+)<.*/, test)
string=(string "|" test[1])
}
startF != 0 && /icon/ {
match($0, /icon ([[:print:]]+) .*/, test)
string=(string "|" test[1])
}
startF != 0 && /cond/ {
match($0, /.*>([[:print:]]+)<.*/, test)
string=(string "|" test[1])
}
startF != 0 && /temp/ {
match($0, /([[:digit:]]+)[^[:digit:]]+([[:digit:]]+)/, test)
string=(string "|" test[1] uniT "|" test[2] uniT "\n")
}
startD != 0 && /icon/ {
gsub(/[[:cntrl:]]/,"")
match($0, /class=.icon ([[:print:]]+).><.*/, test)
iconD=(test[1])
}
startD !=0 && /cond/ {
gsub(/[[:cntrl:]]/,"")
match($0, />([[:alpha:]]+).*<.*>([[:digit:]]+).*<.*/, test)
status=(status "detail|" iconD "|" test[1] " " test[2] uniT)
}
startD !=0 && /realfeel/ {
if (tmpRF)
tmpRF=""
else
tmpRF=uniT
gsub(/[[:cntrl:]]/,"")
match($0, />([[:print:]]+)</, test)
gsub(/&#.{2,3};/,"", test[1])
status=(status "|" test[1] test[2] tmpRF)
}
startD !=0 && /<h4>/ {
gsub(/[[:cntrl:]]/,"")
match($0, />([[:alpha:]]+)</, test)
status=(status "|" test[1])
}
descS !=0 && /stats/ {
getline
getline
match($0, />([[:print:]]+)</, test)
status=(status "|" test[1])
getline
getline
getline
match($0, /([[:alpha:]]+:)<.*>([[:print:]]+)</, test)
status=(status "|" test[1] test[2])
getline
getline
getline
getline
match($0, />([[:print:]]+)</, test)
status=(status "|" test[1])
}
statS !=0 && /stats/ {
getline
match($0, /<li>([[:print:]]+:).<strong>([[:print:]]+)<.strong> *([[:print:]]*)<.li>/, test)
status=(status "|" test[1] " " test[2] " " test[3])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2])
getline
match($0, /<li>([[:print:]]+:).<strong.*>([[:print:]]+)<.strong/, test)
status=(status "|" test[1] " " test[2] "\n")
}
END{
print string
print status
}
Bookmarks