Skip to content

Instantly share code, notes, and snippets.

@kg6zjl
Last active September 22, 2020 23:46
Show Gist options
  • Select an option

  • Save kg6zjl/92c5cfa290021d340514d7faab2b2795 to your computer and use it in GitHub Desktop.

Select an option

Save kg6zjl/92c5cfa290021d340514d7faab2b2795 to your computer and use it in GitHub Desktop.
Pulls the rss feed from Bay Area Air Quality Management District (BAAQMD) to monitor "Spare the Air" / "No Burn Days"
#!/usr/bin/python3
import requests
import xmltodict
rss_feed = "http://www.baaqmd.gov/Feeds/AlertRSS.aspx"
def fetch_feed(url):
r = requests.get(url)
return r.text.strip()
def parse_xml(data):
xml = xmltodict.parse(data)
status = xml['rss']['channel']['item']['description']
date = xml['rss']['channel']['item']['date']
return (f"{ status } for { date }")
if __name__ == '__main__':
data = fetch_feed(rss_feed)
status = parse_xml(data)
print(status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment