Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
666 views
in Technique[技术] by (71.8m points)

ruby on rails - Error: no implicit conversion of Symbol into Integer

I keep getting this error. I'm very confused. This is when I try and scrape a website.

Error: no implicit conversion of Symbol into Integer

Here is the scraper class


class RestaurantsScraper < Kimurai::Base
    @name = "restaurants_scraper"
    @driver = :selenium_chrome
    @start_urls = ["https://www.tripadvisor.com/Restaurants-g31892-Rogers_Arkansas.html"]

    def parse(response, url:, data: {})
        response.xpath("//div[@class=_1llCuDZj]").each do |a|
            request_to :parse_repo_page, url: absolute_url(a[:href], base: url)
        end
    end



    def parse_repo_page(response, url:, data: {})
            item = {}
            item["title"] = t.css('a._15_ydu6b')&.text&.squish&.gsub('[^0-9].', '')
            item["type"] = t.css('span._1p0FLy4t')&.text&.squish
            item["reviews"] = t.css('span.w726Ki5B').text&.squish
            item["top_reviews"] = t.css('a._2uEVo25r _3mPt7dFq').text&.squish

            Restaurant.where(item).first_or_create
            byebug
    end
end

Here is my /scrape in my controller page

    url = "https://www.tripadvisor.com/Restaurants-g31892-Rogers_Arkansas.html"
    response = RestaurantsScraper.parse!(:parse, url: "https://www.tripadvisor.com/Restaurants-g31892-Rogers_Arkansas.html")
    if response[:status] == :completed && response[:error].nil?
      flash.now[:notice] = "Successfully scraped url"
    else
      flash.now[:alert] = response[:error]
    end
  rescue StandardError => e
    flash.now[:alert] = "Error: #{e}"
  end

Here is the error error

question from:https://stackoverflow.com/questions/65921406/error-no-implicit-conversion-of-symbol-into-integer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...