Last active
November 16, 2017 10:25
-
-
Save vnznznz/f3c0309adb7240a20ffcade473426320 to your computer and use it in GitHub Desktop.
Quick and dirty snippet to get the latest ArchLinux - News
This file contains hidden or 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
#!/usr/bin/python | |
""" | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2017 Vinzenz Johann Sinapius <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. | |
""" | |
import requests | |
from lxml import html | |
SITE = "https://www.archlinux.org/news/" | |
TBODY_XPATH = "/html/body/div[2]/div[2]/table/tbody" | |
NEWS_COUNT = 4 | |
if __name__ == "__main__": | |
page = requests.get(SITE) | |
tree = html.fromstring(page.content) | |
table = tree.xpath(TBODY_XPATH)[0] | |
count = 0 | |
for element in table.getchildren(): | |
tds = element.getchildren() | |
timestamp = tds[0].text | |
title = tds[1].getchildren()[0].text.strip() | |
print("%s\t%s" % (timestamp, title)) | |
count += 1 | |
if count >= NEWS_COUNT: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
added license