forked from stanfordjournalism/search-script-scrape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16.py
More file actions
11 lines (11 loc) · 647 Bytes
/
Copy path16.py
File metadata and controls
11 lines (11 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
# The non-profit organization with the highest total revenue, according to the latest listing in ProPublica's Nonprofit Explorer
# Note: "latest listing" is kind of broad...we'll just take that to mean
# top revenue of whatever's currently listed on the site
from lxml import html
import requests
url = 'https://projects.propublica.org/nonprofits/search?c_code%5Bid%5D=&ntee%5Bid%5D=&order=revenue&q=&sort_order=desc&state%5Bid%5D=&utf8=%E2%9C%93'
doc = html.fromstring(requests.get(url).text)
d = doc.xpath('//table/tbody/tr[1]/td/a/text()')
print(d[0])
# It's also possible to just use the API
# https://projects.propublica.org/nonprofits/api