Set a string as the response of a webpage in phantomjs
问题 Hi what i am trying to do is not to get the webpage as page.open(url); but to set a string that has already been retrieved as the page response. Can that be done? 回答1: Yes, and it is as easy as assigning to page.content. It is usually also worth setting a page.url (as otherwise you might hit cross-domain issues if doing anything with Ajax, SSE, etc.), and the setContent function is helpful to do both those steps in one go. Here is the basic example: var page = require('webpage').create();