【发布时间】:2017-06-01 10:37:57
【问题描述】:
我正在尝试从 URL http://wzdig.pbc.gov.cn:8080/dig/ui/search.action?hl=zh-CN&sr=score+desc&q=%E9%93%81&rp=&advepq=%E9%93%81&advoq=&adveq=&ext=&advtime=2&advrange=text%26title 获取 html 代码,这是该网络上的特定搜索。
问题是它打印http://wzdig.pbc.gov.cn:8080/dig/ui/search.action,这是进行空白搜索的结果。我做错了什么?
命令如下:
$ phantomjs get.js 'http://wzdig.pbc.gov.cn:8080/dig/ui/search.action?hl=zh-CN&sr=score+desc&q=%E9%93%81&rp=&advepq=%E9%93%81&advoq=&adveq=&ext=&advtime=2&advrange=text%26title'
和get.js:
var system = require('system');
var page = require('webpage').create();
var system = require('system');
var page = require('webpage').create();
// Imitate a real browser
page.viewportSize = { width: 1440, height: 900 };
page.settings.userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36";
// Called every time a page is loaded
page.onLoadFinished = function(){
// If the real page with search controls is loaded
// then get page.content and exit
var inputCount = page.evaluate(function(){
return document.querySelectorAll("h3").length;
});
if(inputCount > 0) {
console.log(page.content);
phantom.exit();
}
};
page.open(system.args[1]);
【问题讨论】:
-
这与
bash标签有什么关系?,删除它! -
@Igor 你是什么意思?
-
@Igor?但浏览器将其转换为 %E9%93%81 这不是假设工作。我有什么选择?
标签: javascript html phantomjs uri