brent timothy saner on 2 Dec 2018 21:25:43 -0800
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] OT: MontCo Dispatch system web & RSS
|
- From: brent timothy saner <brent.saner@gmail.com>
- To: plug@lists.phillylinux.org
- Subject: Re: [PLUG] OT: MontCo Dispatch system web & RSS
- Date: Mon, 3 Dec 2018 00:25:14 -0500
- Autocrypt: addr=brent.saner@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFKm0mgBEADSI5oeyqRYZ8YWxPbux4CeqaMNh4etuyJmglDRCQB9t1XlvhMDLZWQNqm+ ORBN3YGISUu+X55p10lK/O1w/85zXkAV7Qe6fkvUzSx0tbPWLu4rn4zH9JgTExElhFRv143H W/EKehejEetkNz6JSwGUXNiF5qh1GbKLOmShbmCSKXLcmw05Qj4ELmhkH9OWXpeM0EHmWIEK VSeoIim/g1MYYxKOb1wY3DEubY9zn3lfz9xfLq/xlFMepDyNAEer/qZDSHQqnymdqXlt6L9e mfd4snHLiDfUgG9JOPeMDWeT6XWJDtKKCcZ3JDSMEGgZsFYpwJxJEwPxnfhHJmH8ENxi/8Cu 0fLFvzgAP+VK/Z1egBI7l241fDDREg3e+NWFhUM5bjwBmqk1z8nkRdru+QSMtPl6Erkd+Tbp 7lGGpQwCbI6esdBPkx/nV8+fIPEcsR2G5jG7O9U4J6q3B1nRFrR863SJHudIWV/l59ZvA8kI knDYNOixPLmnoRrO7LNIWe9jpnkZdg34Aa5AjAjGEKwY5EAzqkKuPEMVGqg/36YUcnqYS98W iVgCpaGg6KJqCMVXBfugxd79rtkyT4Oeju/z/Yp2xxXm3Pqcocb1CxbiEYDLJNT7/hyIJ072 4asMz2DTDMIMciP93hPraEtINknPlerNX2XqK03D+gyBGqAL7QARAQABzStCcmVudCBUaW1v dGh5IFNhbmVyIDxicmVudC5zYW5lckBnbWFpbC5jb20+wsF8BBMBAgAmAhsDBwsJCAcDAgEG FQgCCQoLBBYCAwECHgECF4AFAlLzvnsCG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-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to; bh=CHMMgbUW3hG/o6+3HUzyWnof1mNjLamnxnPlQAAWeyw=; b=RCAvYGGUuzFy+77y2RFwXW0WOdrxQeHKu88z1jhjGZpWhJm6gYXMD6UGz72Vsz5kKl 5Wqo17L86/xDeMOPP8AIBfJRKDcU7neYpHdnqVeewGvC5LmlO1/zLHq4EAjp7fLxMw8x L2zUcbz2j6JSZf5nX2LswMpw2cY1bTpac183eovQZqFAyfKt9vyum0IoYrfd96Lltady ELI5HpQZpccrCHhGUF9upn5FF0i+wmaPtYuYl3J4UMxx5/ZeD6VkkWfv7PJKaP6GG2p1 T7P2aNVp2Gnk6sNPDbi1nBRZraU0A4APnNbFHskTXJZHEYsMueUeiVsqsefM5xCqCe0M 6pIw==
- Openpgp: id=748231EBCBD808A14F5E85D28C004C2F93481F6B
- Reply-to: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
- Sender: "plug" <plug-bounces@lists.phillylinux.org>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1
On 12/2/18 8:53 PM, JP Vossen wrote:
>
> Brent, I finally got around to playing with that--very cool! In the
> same spirit of "fun" I grabbed some code out of "6.3 Parsing Simple XML
> Data" from page 183 of _Python Cookbook 3_ and got this much simpler but
> less featurefull version to dump the 2 fields that have the useful content.
>
> ----
> #!/usr/bin/env python3
> # montco_incidents1.py
> # 2018-12-02: JP from "6.3 Parsing Simple XML Data" from page 183 of
> _Python Cookbook 3_
>
> from urllib.request import urlopen
> from xml.etree.ElementTree import parse
>
> def main():
> # Download the RSS feed and parse it
> u = urlopen('https://webapp02.montcopa.org/eoc/cadinfo/livecadrss.asp')
> doc = parse(u)
>
> # Extract and print tags of interest
> for item in doc.iterfind('channel/item') :
>
> title = item.findtext('title')
> description = item.findtext('description')
> #link = item.findtext('link') # Always:
> http://www.montcopa.org/webcad
> #date = item.findtext('pubDate') # Better date in desc.
>
> print(title,description)
>
> if __name__ == '__main__':
> main()
> ----
>
> As usual my MUA is mangling the lines a bit.
>
> Then I really went nuts, because I've got the RSS feed in Liferea, which
> uses SQLite, so...
>
> ----
> $ sqlite3 /path/to/liferea.db
>
> ### Get the key (node_if) for the subscription
> sqlite> select * from node where title like 'Montco%';
> node_id parent_id title type expanded view_mode
> sort_column sort_reversed
> ---------- ---------- ---------- ---------- ---------- ----------
> ----------- -------------
> ctdhnix fmmnrqj MontCo PA rss 0 3
> 0 1
> pusppbl gbhbemq MontCo Inc rss 0 3
> 0 1
>
>
> ### Get local stuff in my RSS DB:
> $ sqlite3 /ssd/home/jp/liferea/liferea.db "select title,description from
> items where node_id = 'pusppbl'" | perl -pe 's!\|<div
> xmlns="http://www.w3.org/1999/xhtml"><p>!\t!; s!;</p></div>!!;
> s/&/&/g;' | egrep 'COLLEGEVILLE|ROYERSFORD|TRAPPE|UPPER PROVIDENCE'
> | cat -n
> ...
>
> ### List the types in my DB
> $ sqlite3 /ssd/home/jp/liferea/liferea.db "select title from items where
> node_id = 'pusppbl'" | sort -u | cat -n
> 1 EMS: ABDOMINAL PAINS
> 2 EMS: ALLERGIC REACTION
> 3 EMS: ALTERED MENTAL STATUS
> ...
> 40 Traffic: ROAD OBSTRUCTION -
> 41 Traffic: VEHICLE ACCIDENT -
> 42 Traffic: VEHICLE FIRE -
>
>
> ### List the cities in my DB
> $ sqlite3 /ssd/home/jp/liferea/liferea.db "select description from items
> where node_id = 'pusppbl'" | cut -d';' -f3 | perl -pe 's/^\s+| +$//g;' |
> sort -u | cat -n
> 1 2018-12-02 @ 03:11:39
> 2 2018-12-02 @ 17:40:21-Station:STA8
> 3 ABINGTON
> 4 AMBLER
> 5 BRIDGEPORT
> 6 BUCKS COUNTY
> ...
> 58 WHITEMARSH
> 59 WHITPAIN
> 60 WORCESTER
> ----
>
> Pretty cool stuff. It might be a fun weekend project to wrap Flask or
> web2py around Brent's code to make a little searchable web GUI.
>
nice job! you could even use the lifearea sqlite DB to reconstruct the
RSS content itself!
do note that if you based a web format around the bit i gave, the feed
seems to have short persistence - they seem to trim their own entries
(which makes sense for such a dynamic-centered realtime feed) so you'd
probably want to either write to disk or store in a DB, etc.
Attachment:
signature.asc
Description: OpenPGP digital signature
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug