Closed wspl closed 8 years ago
Unlike PhantomJS, the page
object in node-phantom-simple does not have any properties. In order to get what would be `page.content`` in PhantomJS, you will need to do the following:
page.get('content', function(err, content) {
// content can be used here.
});
I hope that helps. This is true for all properties that can be found on phantom's api pages
@Reewr Another weird problem. I was trying to get rendered html from http://music.163.com/#/song?id=30841216
but when I usepage.get('content'...)
it only return source-code without javascript render.(e.g. a iframe rendered by javascript is empty)
driver.create({ path: phantomjs.path }, (err, browser) => {
browser.createPage((err, page) => {
page.open('http://music.163.com/#/song?id=30841216', (err, stat) => {
page.get('content', (err, content) => {
console.log('1: ' + stat);
console.log(content);
});
})
});
});
The iframe tag in content
:
<iframe name="contentFrame" id="g_iframe" class="g-iframe" scrolling="auto" frameborder="0" src="about:blank"></iframe>
In chrome:
Thanks.
@Reewr Solved! Sorry for the redundant At.
driver.create({
path: phantomjs.path,
parameters: {
'web-security': false
}
}, (err, browser) => {
browser.createPage((err, page) => {
page.open('http://music.163.com/#/song?id=30841216', (err, stat) => {
page.switchToFrame('contentFrame');
page.get('frameContent', (err, content) => {
console.log('1: ' + stat);
console.log(content);
});
});
});
When I try to get source code from phantomjs,
page.content
is underfined.