Skip to content

Commit

Permalink
add KXAN_allergy_report
Browse files Browse the repository at this point in the history
  • Loading branch information
geeseven committed Sep 12, 2020
1 parent 4e80653 commit e59f9f3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions KXAN_allergy_report
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
# requires requests and rich
from re import findall
from requests import get
from rich.console import Console
from rich.table import Table

url = 'https://media.kxan.com/nxs-kxantv-media-us-east-1/oembed/wx_embed/allergy/allergy_v3.5.js' # noqa: E501

site = get(url, allow_redirects=False, timeout=(3.05, 27))

allergy_regex = r'<div class="allergen_value">(.*)</div><div class="plusecks">'
date_regex = r'<h3 class="allergy_content">(.*)</h3>'

allergies = findall(allergy_regex, site.text)
date = findall(date_regex, site.text)

table = Table(title='KXAN allergy report from {}'.format(date[0]))
table.add_column('allergen')
table.add_column('severity')

for item in sorted(allergies):
# change formatting from 'Oak - High' to ['Oak', 'High']
i = item.split(' - ')
table.add_row(i[0], i[1])

Console().print(table)

0 comments on commit e59f9f3

Please sign in to comment.