Created
September 30, 2020 19:50
-
-
Save HotcockMiami/a17c25bc78a67a251ba0da515faf6b33 to your computer and use it in GitHub Desktop.
PyShop parser
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
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