3 ms·
How stable is the output here? I noticed sections are delimited by '&&', and start with '.<SECTION TITLE>...'. If it's stable, then it might be fun to write a
by craftyguy 8y ago
How stable is the output here? I noticed sections are delimited by '&&', and start with '.<SECTION TITLE>...'.
If it's stable, then it might be fun to write a cli client to query/display this..
- samcheng 8y agoProbably quite stable; this stuff dates back to the telegraph...
- aftbit 8y agoFive minutes in python3 + requests: #!/usr/bin/python import requests import re SHOW_GROUPS = ['SYNOPSIS', 'DISCUSSION', 'MTR WATCHES/WARNINGS/ADVISORIES'] CITY = 'MTR' txt = requests.get('https://forecast.weather.gov/product.php?site=NWS&issuedby='+CITY+'&product=AFD&format=txt&version=1&glossary=0', timeout=30).text m = re.search(r'(?mis)<pre class="glossaryProduct">(.*)</pre>', txt) groups = m.group(1).split('&&\n') for g in groups: m = re.search(r'\.(.*?)\.\.\.', g) if m and m.group(1) in SHOW_GROUPS: print(g.strip()+'\n')
- craftyguy 8y agoYep, not hard if the input is somewhat stable...