-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
executable file
·71 lines (56 loc) · 2.25 KB
/
runner.py
File metadata and controls
executable file
·71 lines (56 loc) · 2.25 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
import feedparser, banner
from rssbot2 import rssbot2
rssbot = rssbot2()
print(banner.rssbot_logo)
print("--------------------------")
print("Title: {}". format(rssbot.title))
print("Agent: {}". format(rssbot.user_agent))
print("Max Feeds: {}". format(rssbot.max_feeds))
rssbot.db_connect()
rssbot.get_feeds()
# iteration cursors (yuck)
i=0 # iterations
p=0 # links processed
a=0 # links added
if rssbot.feeds_count > 0:
print("Aggregating {} Feeds". format(rssbot.feeds_count))
for feed in rssbot.feeds:
rss = feedparser.parse(feed[1],referrer=rssbot.root_url)
if rssbot.debug:
print("--------------------------")
if rss.feed.has_key('title'):
print("RSS Feed Title: {}". format(rss.feed.title))
if (rss.feed.has_key('link')):
print("RSS Feed URL: {}". format(rss.feed.link))
try: rss.status
except:
print('HTTP Status not found.')
else:
http_status = "HTTP Response Status Code: %d" % (rss.status)
print(http_status)
if rss.feed.has_key('title'):
if len(rss.entries) > 0:
for entry in rss.entries:
if entry.has_key('title') and entry.has_key('link'):
id = rssbot.add_link(feed[2],entry.title,entry.link)
try:
if id > 0:
if rssbot.debug:
print("\nAdded Record {}". format(id))
print(str(entry.title))
print(str(entry.link))
a=a+1
except:
print("Exception thrown while processing item.")
p=p+1
else:
print('Unable to parse item. Bad title or link format.')
else:
rssbot.deactivate_feed(feed[2])
i=i+1
rssbot.conn.close()
print("--------------------------")
print("Processed feeds: {}". format(i))
print("Processed items: {}". format(p))
print("Added new links: {}". format(a))