forked from stanfordjournalism/search-script-scrape
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# The latest release date for T-100 Domestic Market (U.S. Carriers) statistics report | ||
from lxml import html | ||
from datetime import datetime | ||
import requests | ||
LANDING_PAGE_URL = 'http://www.transtats.bts.gov/releaseinfo.asp' | ||
doc = html.fromstring(requests.get(LANDING_PAGE_URL).text) | ||
a = doc.xpath("//a[contains(text(), 'T-100 Domestic Market (U.S. Carriers)')]")[0] | ||
tr = a.getparent().getparent() | ||
txt = tr.xpath("./td[3]/text()")[0] # e.g. ['8/13/2015:'] | ||
# messy | ||
dt = datetime.strptime(txt, '%m/%d/%Y:') | ||
print(dt.strftime("%Y-%m-%d")) | ||
# 2015-08-13 |