我使用X 射线刮刀将 JSON 流式传输到浏览器:
app.get('/scrape', function (req, res) {
// other code
var stream = x(siteUrl, site.item, site.params)
.paginate(site.paginate)
.stream();
stream.pipe(res);
// other code
});
我用下面的 ajax onprogress 事件抓住了它:
$.ajax('/scrape', {
xhrFields: {
onprogress: function (e) {
console.log(e.currentTarget.response.length); // here is problem
// other code
}
}
}
这里的一切都在本地主机上运行良好,但是当我通过公共 IP 运行它时,响应会被随机剪切,并且看起来像这样(换句话说,我无法正确处理响应,因为 json 被剪切了):
{
"title": "Some Title",
"link": "http://some...