Comments (7)
What other methods? I would like to know please.
from node-phantom.
+1 by the way.
from node-phantom.
You just need to evaluate document.documentElement.innerHTML inside the opened page, like I do here after a timeout, to take into account presence of Javascript inside the page that could modified it on load:
var phantom=require('node-phantom');
var waitTime = 5000;
phantom.create(function(err,ph) {
return ph.createPage(function(err,page) {
/* to show browser console.log
page.onConsoleMessage = function(msg) {
console.log(msg);
}; */
var pstr = "http://www.google.com";
console.log("browsing to ", pstr);
return page.open(pstr, function(err,status) {
console.log("opened site? ", status);
if ( status === "success" ) {
setTimeout(function(){
var p = page.evaluate(function () {
return document.documentElement.innerHTML;
}, function(err,result){
if (err) {
console.log("Error!");
} else {
console.log("***** The html is: *****");
console.log(result);
}
ph.exit();
});
}, waitTime)
};
});
});
});
from node-phantom.
You can get to page.content through the page.get function
page.get('content',function(err,content){
//content will now be 'page.content'
});
from node-phantom.
in code:
page.get('content',function(err,content){
//content will now be 'page.content'
});
page content consist in variable err
PS: Sorry fo my english:(
from node-phantom.
@alexscheelmeyer We are getting content in err
object of page.get('content', function(err, content){})
function and content
object is undefined. Has the callback method signature changed since this answer was posted?
Thanks,
Raeesaa
from node-phantom.
@raeesaa
This should work:
page.get('content',function(content){
//content will now be in var 'content'
});
from node-phantom.
Related Issues (20)
- I want import a method execute in page.evaluate
- can page.render to stream HOT 1
- `phantom.create` fails with no trace or error
- phantom.create fails
- callback of page.render didn't work HOT 2
- first time execute ph.createPage , socket.io seems not prepared
- deploy our node with pm2 cluster mode . will it work well .
- createPage does not callback HOT 6
- meet phantom stdout: TypeError: undefined is not an object (evaluating 'phantom.args[0]') HOT 6
- pageOnError suppress errors
- pass quality parameter to render
- How to add cookie? HOT 3
- Wrong usage example
- Whitespace issue in the binary path
- page.includeJs hangs on https
- Add disclaimer: ABONDENED PROJECT HOT 4
- create page of undefined
- ssl error HOT 1
- ph is undefined HOT 1
- evaluate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-phantom.