Skip to content

Instantly share code, notes, and snippets.

@HotcockMiami
Created September 30, 2020 19:50
Show Gist options
  • Save HotcockMiami/a17c25bc78a67a251ba0da515faf6b33 to your computer and use it in GitHub Desktop.
Save HotcockMiami/a17c25bc78a67a251ba0da515faf6b33 to your computer and use it in GitHub Desktop.
PyShop parser
from lxml import html
import urllib3
http = urllib3.PoolManager()
r = http.request('GET', 'http://python.org')
data = html.fromstring((r.data).decode("utf8"))
divs = data.xpath('//div[@class = "medium-widget event-widget last"]')[0]
ULs = divs.xpath('.//ul')[0]
LIs = ULs.xpath('.//li')
rez = {}
for item in LIs:
date = item.xpath('.//time/@datetime')[0]
event = item.xpath('.//a/text()')[0]
rez[event]=date[0:10]
print (rez)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment