-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrape_bbc.py
executable file
·43 lines (33 loc) · 914 Bytes
/
scrape_bbc.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
scrape_bbc.py - scrape BBC's RSS site for news headlines
"""
import unittest
from pprint import pprint
from scraper_base import ScraperBase
class ScrapeBBC(ScraperBase):
"""
scrape BBC's RSS site for news headlines
"""
def scrape_worker(self):
"""
abstract method implementation - does all the scraping work
"""
s_url = "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/" + \
"americas/rss.xml"
feed = self.fetch_rss(s_url)
return [post.title for post in feed.entries]
class ModuleTests(unittest.TestCase):
"""
module tests
"""
@staticmethod
def test01():
"""
tests class derivation and scraping
"""
sobj = ScrapeBBC("scrape_bbc.log", "DEBUG")
pprint(sobj.scrape())
if __name__ == "__main__":
unittest.main()