Skip to content

Instantly share code, notes, and snippets.

@carter-yagemann
Created January 13, 2017 17:48
Show Gist options
  • Save carter-yagemann/e0f42d84a7b490d45551b364aca39df0 to your computer and use it in GitHub Desktop.
Save carter-yagemann/e0f42d84a7b490d45551b364aca39df0 to your computer and use it in GitHub Desktop.
Phrack RSS
"""
phrack-rss.py - Generates a RSS feed for Phrack's releases.
Copyright (c) 2016 Carter Yagemann
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available at
<http://www.gnu.org/licenses/>.
"""
from feedgen.feed import FeedGenerator
import re
import requests
def getnum(s):
return int(re.findall('\d+', s)[0])
def gettgzs():
dir = requests.get('http://www.phrack.org/archives/tgz/')
if dir.status_code == 200:
return sorted(set(re.findall('phrack\d+.tar.gz', dir.text)), key=getnum)
else:
return []
def makefeed(tgzs):
fg = FeedGenerator()
fg.id('phrack-rss')
fg.title('Phrack News')
fg.description('Archive for Phrack News')
fg.link(href='http://www.phrack.org/archives/tgz/', rel='alternate')
fg.language('en')
for tgz in tgzs:
fe = fg.add_entry()
url = 'http://www.phrack.org/archives/tgz/' + tgz
fe.id(url)
fe.title(tgz)
fe.description('Get ' + tgz + ' at ' + url)
fe.content(src=url)
fe.link(href=url)
return fg
tgzs = gettgzs()
if len(tgzs) > 0:
print makefeed(tgzs).rss_str()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment