A function that functions as ready() or $(window).load() of js in ruby grammar

Asked 2 years ago, Updated 2 years ago, 90 views

To get information that Naver API doesn't provide, I'm crawling directly on the Naver map site.

But after doing it, NAVER map is loaded in double?This

I think it's working.

After loading the basic frame, And then, I think it's like filling up the contents with search words.

So I think I need to crawl when all the documents are loaded

I would like to know if there is a function in ruby that shows when such loading is complete.

Or I would like to know if there is another way to solve the above problem.

ruby crawling

2022-09-22 21:16

1 Answers

After the page loads in the browser, you need to receive the result of the script working on the client to get the result you want. To do that, you need to run a real browser and use tools like selenium to get results.

If you refer to the code below, run a browser and map.Read naver.com and save the results to the doc. Now, you can use the function of Nokogiri to read the value you want.

require 'selenium-webdriver'
require 'nokogiri'

driver = Selenium::WebDriver.for :safari
driver.get "http://map.naver.com"

doc = Nokogiri::HTML(driver.page_source)

I used Safari browser. When Selenium::WebDriver.for:firefox, run Firefox to read the results.


2022-09-22 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.