Class: Hongkong::News::Scrapers::AppleDailyScraper
- Inherits:
-
Object
- Object
- Hongkong::News::Scrapers::AppleDailyScraper
- Includes:
- PhantomScraper
- Defined in:
- lib/hongkong/news/scrapers/apple_daily_scraper.rb
Instance Method Summary collapse
-
#news(url) ⇒ Object
Extract article from page from Apple Daily.
-
#news_links ⇒ Object
Extract all news links from Apple Daily.
Methods included from PhantomScraper
Instance Method Details
#news(url) ⇒ Object
Extract article from page from Apple Daily
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hongkong/news/scrapers/apple_daily_scraper.rb', line 22 def news(url) visit url document = Document.new document.source = 'appledaily' document.title = first("#articleContent h1").text.strip document.url = url document.html = html document.content = page.evaluate_script("HongKongNews.getInnerText('#masterContent')") document.screenshot_data = screenshot_data document end |
#news_links ⇒ Object
Extract all news links from Apple Daily
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hongkong/news/scrapers/apple_daily_scraper.rb', line 10 def news_links visit "http://hk.apple.nextmedia.com/" all("#article_ddl option").collect do |option| link = Link.new link.title = option.text link.url = option["value"] link end end |