1 from bs4 import BeautifulSoup
2 import generic_news_rss_renderer
5 class google_news_rss_renderer(generic_news_rss_renderer.generic_news_rss_renderer):
6 def __init__(self, name_to_timeout_dict, feed_site, feed_uris, page_title):
7 super(google_news_rss_renderer, self).__init__(
14 def debug_prefix(self):
17 def get_headlines_page_prefix(self):
20 def get_details_page_prefix(self):
21 return "google-news-details"
23 def find_description(self, item):
24 descr = item.findtext('description')
25 source = item.findtext('source')
26 if source is not None:
27 descr = descr + " (%s)" % source
30 def munge_description_internal(self, descr):
33 descr = re.sub(r"\<[^\>]*$", "", descr)
34 descr = descr + " [...]"
35 descr += "</A></LI></UL></OL></P>"
38 def munge_description(self, description):
39 soup = BeautifulSoup(description)
40 for a in soup.findAll('a'):
43 return munge_description_internal(descr)
45 def find_image(self, item):
48 def should_use_https(self):
51 def item_is_interesting_for_headlines(self, title, description, item):
52 return not self.is_item_older_than_n_days(item, 2)
54 def item_is_interesting_for_article(self, title, description, item):
55 return not self.is_item_older_than_n_days(item, 2)
58 #x = google_news_rss_renderer(
60 # "Shuffle News" : 1},
62 # [ "/rss?hl=en-US&gl=US&ceid=US:en" ],
64 #if x.fetch_news() == 0:
65 # print("Error fetching news, no items fetched.")
68 #descr = "this is a lot of really long text about nothign in particular. It's pretty interesting, don't you think? I hope that the munge description method works by both truncating it and remembering to close any open <LI>items as well as making sure not to truncate in the middle of a <A HREF=\"whatever\" these are a bunch of useless arguments to the A tag that make it really long so that the truncate will happen in the middle of it. I'm getting kind of tired of typing shit so I'm going to revert to copy pasta now. Sorry if you were getting into this story. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</A></LI> Out!"
69 #d = x.munge_description_internal(descr)