-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathri.py
30 lines (26 loc) · 886 Bytes
/
ri.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import dateutil.parser
import requests
import logging
import lxml.html
from executiveorder import executiveorder
url = "https://governor.ri.gov/executive-order-archive"
page = requests.get(url).content
page = lxml.html.fromstring(page)
page.make_links_absolute(url)
for row in page.xpath("//table[contains(@class,'views-table')]/tbody/tr"):
identifier = row.xpath("td[2]/a[1]")[0].text_content()
html_url = row.xpath("td[2]/a[1]/@href")[0]
title = row.xpath("td[3]")[0].text_content()
pubdate = row.xpath("td[1]")[0].text_content().strip()
pubdate = dateutil.parser.parse(pubdate)
eo = executiveorder.executiveorder(
abbr="ri",
identifier=identifier,
ocd_id="ocd-division/country:us/state:ri",
html_url=html_url,
published=pubdate,
source_url=url,
title=title,
)
logging.info(eo)
eo.save()