Skip to content

Commit

Permalink
[#7] Add error handling into google parser
Browse files Browse the repository at this point in the history
  • Loading branch information
malparty committed Jun 30, 2021
1 parent 84d4330 commit b5abfeb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/services/google_service/parser_service.rb
Expand Up @@ -6,9 +6,11 @@ class ParserService

NON_ADS_RESULT_SELECTOR = 'a[data-ved]:not([role]):not([jsaction]):not(.adwords):not(.footer-links)'

def initialize(html)
@html = html
@document = Nokogiri::HTML.parse(html)
def initialize(html_response)
raise ArgumentError, 'response.body cannot be nil' if html_response.body.blank?

@html = html_response
@document = Nokogiri::HTML.parse(html_response)

# Add a class to all AdWords link for easier manipulation
@document.css('div[data-text-ad] a[data-ved]').add_class('adwords')
Expand Down Expand Up @@ -53,8 +55,6 @@ def non_ads_url
end

def total_link_count
Rails.logger.info 'Counter HERE!!!'
@document.css('a').map { |a_tag| Rails.logger.info a_tag['href'] }
@document.css('a').count
end
end
Expand Down

0 comments on commit b5abfeb

Please sign in to comment.