-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsscryptome.py
More file actions
executable file
·44 lines (37 loc) · 1.29 KB
/
Copy pathrsscryptome.py
File metadata and controls
executable file
·44 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import urllib2
import re
use_cache = 0
if use_cache == 0:
content = urllib2.urlopen('http://www.cryptome.org').read()
f = open ("cryptome.txt", "w")
f.write(content)
f.close()
else:
f = open("cryptome.txt", "r")
content = f.read()
f.close()
content = content.split("<PRE>")
content = content[1]
href = re.finditer(r'<B><A HREF="http:\/\/(.*)">(.*)<\/A>[^\)](.*)<\/B>', str(content))
count = 0
rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\">\n<channel>\n<title>RSS Feed Cryptome Latest</title><link>http://www.cryptome.org</link><description>Latest top 10 news items on Cryptome</description>"
for i in href:
count +=1
if count <= 10:
url = i.group(1)
doc = i.group(1)
doc = doc.split('/')
doc = doc[-1]
texts = i.group(3)
text = re.sub(r' ( +)', " ", texts)
text = re.sub(r'\(<A(.*)>(.*)<\/A>\)', "", text, re.I)
date = re.search(r'([a-zA-Z]+) [0-9]{1,2}\, [0-9]{4}', texts, re.I)
text = text.replace(" "+date.group(), "")
rss += "\n<item>\n<title># : "+str(count)+"</title>\n<pubDate>"+date.group().replace(',','')+"</pubDate>\n<description>"+text+"\nDoc : "+doc+"</description>\n<link>http://"+url+"</link>\n</item>\n"
else:
break
rssnews = rss + "\n</channel>\n</rss>\n"
f = open("cryptnews.xml", "w")
f.write(rssnews)
f.close()