Class: NewsScraper::Extractors::GoogleNewsRss
- Inherits:
-
Object
- Object
- NewsScraper::Extractors::GoogleNewsRss
- Includes:
- NewsScraper::ExtractorsHelpers
- Defined in:
- lib/news_scraper/extractors/google_news_rss.rb
Constant Summary collapse
- BASE_URL =
'https://news.google.com/news?cf=all&hl=en&pz=1&ned=us&output=rss'.freeze
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(query:) ⇒ GoogleNewsRss
constructor
A new instance of GoogleNewsRss.
Methods included from NewsScraper::ExtractorsHelpers
Constructor Details
#initialize(query:) ⇒ GoogleNewsRss
Returns a new instance of GoogleNewsRss.
10 11 12 |
# File 'lib/news_scraper/extractors/google_news_rss.rb', line 10 def initialize(query:) @query = query end |
Instance Method Details
#extract ⇒ Object
14 15 16 17 18 19 |
# File 'lib/news_scraper/extractors/google_news_rss.rb', line 14 def extract http_request "#{BASE_URL}&q=#{@query}" do |response| google_urls = google_urls_from_resp(response.body) extract_article_urls(google_urls) end end |