Loading webpage incompletely Phantomjs

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I have problems capturing and loading the webpage: https://myaccount.nytimes.com/auth/login

The username and password fields as well as the submit button are missing. What could be the reason? Thanks

As you can see the code listed below waits for each and all the resources to be loaded, one by one.

I did not write the code, however it is excellent and tested by many. The original can be found here: https://gist.github.com/cjoudrey/1341747 (ALL the credits to the guy who wrote it.)

    var resourceWait  = 3000,
    maxRenderWait = 30000,
   url = 'https://myaccount.nytimes.com/auth/login'; //'https://twitter.com/#!/nodejs';

   var page          = require('webpage').create(),
   count         = 0,
   forcedRenderTimeout,
   renderTimeout;

   page.viewportSize = { width: 1280, height : 1024 };

   function doRender() {
      page.render('twitter.png');
      phantom.exit();
   }

   page.onResourceRequested = function (req) {
      count += 1;
      console.log('> ' + req.id + ' - ' + req.url);
      clearTimeout(renderTimeout);
   };

   page.onResourceReceived = function (res) {
     if (!res.stage || res.stage === 'end') {
        count -= 1;
        console.log(res.id + ' ' + res.status + ' - ' + res.url);
        if (count === 0) {
           renderTimeout = setTimeout(doRender, resourceWait);
        }
     }
   };

  page.open(url, function (status) {
     if (status !== "success") {
        console.log('Unable to load url');
        phantom.exit();
     } else {
        forcedRenderTimeout = setTimeout(function () {
           console.log(count);
           doRender();
        }, maxRenderWait);
     }
  });
asked 1 min ago
MiMehe

نویسنده : استخدام کار بازدید : 10 تاريخ : چهارشنبه 23 خرداد 1397 ساعت: 8:58

فهرست وبلاگ