SOA-nuts / api-PortfolioAdvisor

0 stars 0 forks source link

crawler EOFerror #19

Open ShinRuHung opened 2 years ago

ShinRuHung commented 2 years ago

try to fix with

require 'rubygems'
require 'mechanize'

module PortfolioAdvisor
  module Crawler
    # Display content of HTML articles
    class Api
      attr_reader :url

      def initialize(url)
        @url = url
      end

      def crawl
        content_exist?
      rescue StandardError
        raise 'NotFound'
      end

      def content_exist?
        agent = Mechanize.new
        html_text = agent.get(@url).body
        open_article = Nokogiri::HTML(html_text)
        open_article.css('p').map(&:text)
      end
    end
  end
end
ShinRuHung commented 2 years ago

https://www.androidpolice.com/google-removes-all-traces-of-the-buggy-december-2021-update-for-the-pixel-6-and-6-pro/

this url raise error, can use for test