JSDOM在cloudfoundry上抓取不起作用 [英] JSDOM scraping on cloudfoundry doesn't work
问题描述
我正在为应用程序使用jsdom node.js模块,该应用程序会进行一些Web抓取以获得所需的数据.当我在本地运行时,效果很好.
I'm using the jsdom node.js module for an app that does some web scraping to get some data it needs. This works perfectly fine when I run locally.
但是,当我将应用程序推送到cloudfoundry时,它崩溃了.日志如下:
When I push the application to cloudfoundry however, it crashes. The log is as follows:
====>/logs/stderr.log< ====
====> /logs/stderr.log <====
/var/vcap/data/dea/apps/caretogethersandbox-0-8b20af9255bbf552d0f490cb60d0df55/app/node_modules/jsdom/lib/jsdom.js:171功能= JSON.parse(JSON.stringify(window.document.implementation._fea^ TypeError:无法读取未定义的属性实现"
/var/vcap/data/dea/apps/caretogethersandbox-0-8b20af9255bbf552d0f490cb60d0df55/app/node_modules/jsdom/lib/jsdom.js:171 features = JSON.parse(JSON.stringify(window.document.implementation._fea ^TypeError: Cannot read property 'implementation' of undefined
我这里缺少什么吗?我很沮丧.我知道我编写的代码可以正常工作,这似乎只是模块和cloudfoundry之间的问题.
Is there something I'm missing here? I'm pretty stumped. I know the code I've written works fine, it just seems to be an issue between the module and cloudfoundry.
推荐答案
我能够轻松重现此问题.看来jsdom依赖于一个名为Contextify( https://github.com/brianmcd/contextify 的本地编译库.),并且据我所知对Python有一些绑定.目前,Cloud Foundry不支持这些功能.Github上也有类似的问题;
I was able to reproduce this problem pretty easily. It seems jsdom relies on a native compiled library called Contextify (https://github.com/brianmcd/contextify) and also has some bindings to Python from what I can gather. These are not supported by Cloud Foundry at present. There is a similar question on Github about this problem;
https://github.com/tmpvar/jsdom/issues/436
撰写本文时的最后一篇文章建议使用两个100%的JS库,称为Domino和Zepto Node,它们很值得一试.
The last post at the time of writing this suggests the use of two 100% JS libraries called Domino and Zepto Node, they may well be worth checking out.
这篇关于JSDOM在cloudfoundry上抓取不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!