A
A
Andrey2017-07-06 15:10:55
ruby
Andrey, 2017-07-06 15:10:55

How to set a delay during parsing?

I need to retrieve data from a table.
But the problem is that the table is built from the soap request and after the page has loaded.
Those. Roughly speaking, the whole page is built and then you have to wait a couple more seconds for the table I need to appear.

url = "my_url" 
html = open(url) # запрос на удаленный сервер
# Вот в этом месте, как я понял, страница открывается но без нужной мне таблицы. метод sleep() не помогает.
doc = Nokogiri::HTML(html) # получаю код
doc.css('td[data-href]') # нужные мне данные из тадлицы

Help, in which direction to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
oh_shi, 2017-07-06
@oh_shi

No way. You made a request, received a response, parsed. You seem to have a problem with the fact that the page still has js, which additionally loads something via ajax. Here, either pull out this ajax request and parse data from it, or use something like Capybara + PhantomJS to mimic the behavior of the browser.

A
Andrey Andreev, 2017-07-06
@b0nn1e

In the direction of how the site that you parse works.
See where the request goes for data from the table, and immediately take it from there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question