Casperjs Scraping Dynamic Content
I'm trying to scrape this page using Casperjs. The main function to my code works just fine, but the content is loaded dynamically and I can't figure out how to trigger that. This
Solution 1:
I've looked to the page. It has such a behvior that it doesn't load the middle images when you jump to the end.
When the page is loaded the first couple of rows are completely loaded and some more are not completely loaded (image missing denoted by '.loading-msg'
element). When you jump to the end with this.scrollToBottom();
there is no continous scroll. It jumps to the end and the page JavaScript doesn't detect that the middle images were in the viewport, however briefly. The page goes on to load the next rows, but not the missing images of the jumped over rows.
You have to reduce the distance of the jump in both of your snippets.
The first one can be changed like this:
var pos = 0,
height = casper.page.viewportSize.height;
casper.waitFor(function() {
this.scrollTo(0, pos * height);
return !this.exists('.loading-msg');
}, function() { // do stuff }, 20000);
The second one might work by changing
this.page.scrollPosition = { top: this.page.scrollPosition["top"] + 4000, left: 0 };
to
var height = casper.page.viewportSize.height;
this.page.scrollPosition = { top: this.page.scrollPosition.top + height, left: 0 };
Post a Comment for "Casperjs Scraping Dynamic Content"