title: PhantomJS- open page with LocalStorage by default
body: <p>I'm using <a href="http://phantomjs.org/" rel="noreferrer">PhantomJS</a> to get the generated source of a web page after JavaScript DOM manipulations have taken place. This web page has JUST a <code>&lt;body&gt;</code> and nothing else. </p>
  
  <p><strong><em>Important</em></strong>: This web page uses browser's <code>localStorage</code> to generate the page.</p>
  
  <p>I want to change LocalStorage in PhantomJS before opening the page.</p>
  
  <p><strong>App.js</strong>:  </p>
  
  <pre><code>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)
  </code></pre>