Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save logan4dog/62c4067d3ebc577e20eeba807a86370c to your computer and use it in GitHub Desktop.
Save logan4dog/62c4067d3ebc577e20eeba807a86370c to your computer and use it in GitHub Desktop.
lxml xpath web scraping for the interior dept page table of monuments Donald J Trump wants to reduce in size or elimate all together
import requests
from lxml import html
pageContent=requests.get('https://www.doi.gov/pressreleases/interior-department-releases-list-monuments-under-review-announces-first-ever-formal')
tree = html.fromstring(pageContent.content)
#monument
tree.xpath('//*[@property="content:encoded"]//tr/td[1]/text()')
#location
tree.xpath('//*[@property="content:encoded"]//tr/td[2]/text()')
#years
tree.xpath('//*[@property="content:encoded"]//tr/td[3]/text()')
#acreage
tree.xpath('//*[@property="content:encoded"]//tr/td[4]/text()')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment