Please help me how to acess a conent created after scrolling

10 views
Skip to first unread message

Yuna Yoon

unread,
Apr 14, 2015, 12:55:10 PM4/14/15
to phan...@googlegroups.com

Hello everyone!

Could anybody let me know how to access or inspect a page.content which is created after scrolling dynamically?

"var content = page.content" inside here   is created after scrolling.

And I want to evaluate some functions with this content like "document.getElementsByClassName.."

Please Help .....

 



var page = require('webpage').create();
var fs = require("fs");
page.viewportSize = { width: 1280, height: 800 };
page.scrollPosition = { top: 0, left: 0 };
url = "test.com";


page.open(url, function(status) {
   if (status === 'fail') {
      console.error('webpage did not open successfully');
      phantom.exit(1);
   }
   else{
      var i = 0, top, chk = 0, queryFn = function() { return document.body.scrollHeight; };

      setInterval(function() {
       
         top = page.evaluate(queryFn);
         page.scrollPosition = { top: top + 1, left: 0 };
    
         if (chk === top) {



                     var content = page.content;          //     create new page.content after scrolling
                                                                           //     how to access this "var content"

                                                                           //     by using document.getElementsByClassName or querySelector, .....



             phantom.exit();
         }
         chk = top;
      }, 2000);
   }
});

Reply all
Reply to author
Forward
0 new messages