Class: Weneedfeed::Scraping
- Inherits:
-
Object
- Object
- Weneedfeed::Scraping
- Defined in:
- lib/weneedfeed/scraping.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'User-Agent' => 'Weneedfeed' }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Weneedfeed::Page
-
#initialize(description:, item_description_selector:, item_image_selector:, item_link_selector:, item_time_selector:, item_title_selector:, item_selector:, title:, url:) ⇒ Scraping
constructor
A new instance of Scraping.
Constructor Details
#initialize(description:, item_description_selector:, item_image_selector:, item_link_selector:, item_time_selector:, item_title_selector:, item_selector:, title:, url:) ⇒ Scraping
Returns a new instance of Scraping.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/weneedfeed/scraping.rb', line 30 def initialize( description:, item_description_selector:, item_image_selector:, item_link_selector:, item_time_selector:, item_title_selector:, item_selector:, title:, url: ) @description = description @item_description_selector = item_description_selector @item_image_selector = item_image_selector @item_link_selector = item_link_selector @item_time_selector = item_time_selector @item_title_selector = item_title_selector @item_selector = item_selector @title = title @url = url end |
Class Method Details
.faraday_connection ⇒ Faraday::Connection
14 15 16 17 18 |
# File 'lib/weneedfeed/scraping.rb', line 14 def faraday_connection @faraday_connection ||= ::Faraday.new(headers: DEFAULT_HEADERS) do |connection| connection.use ::Weneedfeed::FaradayResponseMiddleware end end |
Instance Method Details
#call ⇒ Weneedfeed::Page
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/weneedfeed/scraping.rb', line 53 def call ::Weneedfeed::Page.new( description: @description, node: parsed_body, item_description_selector: @item_description_selector, item_image_selector: @item_image_selector, item_selector: @item_selector, item_link_selector: @item_link_selector, item_time_selector: @item_time_selector, item_title_selector: @item_title_selector, title: @title, url: @url ) end |