如何使用与phantomjs
问题描述:
我试图用phantomjs 例如写javascript:如何使用与phantomjs
var webPage = require('webpage');
var page = webPage.create();
page.open('http://www.w3school.com.cn',
function() {
var res = page.evaluate(function() {
return document.getElmentsByTagName('a');
});
console.log(res);
phantom.exit();
});
乳宁,错误提示:
TypeError: 'undefined' is not a function (evaluating 'document.getElmentsByTagName('a')')
phantomjs://webpage.evaluate():2
phantomjs://webpage.evaluate():3
phantomjs://webpage.evaluate():3
null
为什么我做了什么?
我在代码中看不到'document.getElmentById',但只有'getElmentsByTagName'。他们都有错别字。它应该是'getElementById'或'getElementsByTagName'。请显示与错误消息相匹配的代码。 – 2014-09-29 06:08:04
你可以尝试阅读状态吗?例如:'page.open('...',function(status){' 'console.log(status);' “success''。或者是错误的错误? – 2014-09-29 07:16:39
如你所愿,成功但仍然报告TypeError:'undefined'不是一个函数... @ AgashThamo。 – noob123 2014-09-29 07:27:46