Answer the question
In order to leave comments, you need to log in
How to update a document in Phantomjs after an action has been performed?
I want to collect all the information from a particular category in a single call to Phantomjs (walk through the pagination by switching pages). The fact is that the site, when you click on the page number / arrow, changes the target block with information and the URL of the page via ajax, i.e. The page is not reloaded. Phantomjs does not understand this and continues to take information from the originally loaded page. The option to run page.open
several times with a change in URL is not very good, it will take too long to load and the load will be too large.
Sample code:
page.open(url, function (status) {
var data = page.evaluate(function() {
//Пока стрелка вправо активна, нажимаем на неё
while ($('.arrow_right').hasClass('disabled') === false) {
//Логика сбора данных
//Нажимаем на стрелку
var ev = document.createEvent("MouseEvents");
ev.initEvent("click", true, true);
document.querySelector('.arrow_right').dispatchEvent(ev);
//Так подозреваю, что здесь что-то надо сделать
}
return dataOnPage;
});
console.log(data);
phantom.exit();
});
site.ru/category/page/1/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question