我正在尝试使用phantomjs从以下URL获取响应:-
https://www.trivago.com/api/v1/bin/accommodation/2891353/deals?iPathId=34812&iRoomType=1&aRooms=&aDateRange%5Barr%5D=2017-05-24&aDateRange%5Bdep%5D=2017-05-25&bSharedRooms=false幻影代码:-
var system = require('system');
var webPage = require('webpage');
var page = webPage.create();
var url = system.args[1];
page.viewportSize = {
width: 1280,
height: 720
};
page.open(url, function (status) {
var content = page.content;
console.log(content);
phantom.exit();
});但我只得到了<html><head></head><body></body></html>作为响应,而不是完整的响应。我在这里做错了什么?
发布于 2017-05-12 18:43:53
我在Google Chrome中打开了你的链接,下载了一个二进制文件。
标头检查确认:
content-encoding: gzip
content-length: 4160
content-type: application/octet-streamPhantomJS只能打开超文本标记语言页面,因此在脚本或任何页面结构中都得不到响应。
既然此API不需要任何凭据,为什么不直接通过wget/cURL或您选择的语言下载交易文件呢?
https://stackoverflow.com/questions/43931147
复制相似问题