【发布时间】:2015-02-28 11:21:51
【问题描述】:
我正在尝试在搜索结果页面上获取 Google 的“人们也搜索”内容,并且我正在使用 PhantomJS 来抓取他们的结果。但是,我需要的知识库部分没有出现在我得到的body 中。有谁知道我可以做些什么来让我看到它?
代码如下:
var phantom = require('phantom');
phantom.create(function (ph) {
ph.createPage(function (page) {
page.open("http://www.google.com/ncr", function (status) {
console.log("opened google NCR ", status);
page.evaluate(function () { return document.title; }, function (result) {
console.log('Page title is ' + result);
page.open("https://www.google.com/search?gws_rd=ssl&site=&source=hp&q=google&oq=google", function (status) {
console.log("opened google Search Results ", status);
page.evaluate(function () { return document.body; }, function (result) {
console.log(result);
ph.exit();
});
});
});
});
});
});
PS 我必须先请求 `google.com/ncr' 来强制加载 Google.Com 的结果,因为我在德国,而德语版本没有知识图谱。也许上面的请求也可以简化...
【问题讨论】:
标签: javascript node.js phantomjs