lundi 8 février 2016

PhantomJs - Set LocalStorage

I'm using PhantomJs for get generated source of a web page after javascript DOM manipulations have taken place. This web page have JUST a and nothing else. Other objects are made in javascript files.

Important Notice:
This web page using browser's LocalStorage for generate page.

My Issue: set LocalStorage in phantomjs before get page's content.

App.js:

var page = require('webpage').create();

page.open("https://sample.com")
setTimeout(function(){
    // Where you want to save it    
    page.render("screenshoot.png")  
    // You can access its content using jQuery
    var fbcomments = page.evaluate(function(){
        return $("body").contents().find(".content") 
    }) 
    phantom.exit();
},1000)




Aucun commentaire:

Enregistrer un commentaire