我正在阅读一个网页,我必须登录然后传递我的搜索字符串。
每次我想读取结果时,我都必须调用 phantom.exit() 我确实得到了结果,但是对于每个查询我都必须再次登录,这会降低脚本的性能。
有没有办法在不杀死幻影的情况下读取内存中的结果?
下面是一个快速片段,我在其中获取给定公司的 URL 和电话号码。我在控制台上获取该信息的唯一方法是调用 phanton.exit()
if (url == infoPage) {
page.evaluate(function () {
if ($('.companyURL > a')
.length > 0) {
console.info($('.companyURL > a')
.text());
} else {
console.info("Company URL not present");
} if ($('.tel')
.text()) {
console.info($('.tel')
.text());
} else {
console.info("Company Telephone not present");
}
});
phantom.exit();