使用CasperJS进行Web抓取会返回未记录的奇怪错误 [英] Web scraping with CasperJS returns strange error that isn't documented

查看:86
本文介绍了使用CasperJS进行Web抓取会返回未记录的奇怪错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用CasperJS编写了一个Web抓取脚本,它在具有CasperJS 1.1.0-beta3版本和PhantomJS版本1.9.8的Mac OS 10.10.4上完美运行,但是当我将同一脚本放在其中一台服务器上时,具有相同环境(CasperJS和PhantomJS所有相同版本)的Ubuntu 14.04(在Docker容器中运行)突然突然输出以下内容:

I wrote an web scraping script with CasperJS and it works perfectly on Mac OS 10.10.4 with CasperJS version 1.1.0-beta3 and PhantomJS version 1.9.8, but when I put the same script on one of my servers which is Ubuntu 14.04 (running inside Docker container) with the same environment (CasperJS and PhantomJS all the same versions) it suddenly just outputs this:

我是fs模块

I'm `fs` modules

这很奇怪.我的建议之一是,在此脚本中,我还尝试要求其他一些具有require这样的脚本:

Which is pretty strange. One of my suggestion is that in this script I am also trying to require some other scripts with require like that:

var parsingStrategy = require(strategiesPath + strategyName);

这些策略的路径是正确的,我已经检查过了.我在此脚本中所做的所有其他操作都是正常的CasperJS内容,这些内容已记录在案,并且我认为它们可以很好地工作.

and the path to those strategies is correct I already checked that. All the other stuff that I'm doing in this script are just normal CasperJS stuff which are documented and work well I think.

推荐答案

好的,我有一个答案-'fs'是带有节点的捆绑模块,所以它没有通过npm安装.您下载的软件包是这样的: https://www.npmjs.com/package/fs 它所包含的只是...

Okay guys I have an answer for you - the 'fs' is a module bundled with node, so it doesn't have to be installed through npm. The package you downloaded is this: https://www.npmjs.com/package/fs and all it contains is...

console.log("I'm `fs` modules");

当您这样做时:

npm uninstall fs

npm install -g fs

该节点使用其本地软件包(它附带了该软件包),而完全忽略了全局软件包.谜团已揭开. ;)

The node used its local package - that it shipped with - and ignored the global one entirely. Mystery solved. ;)

这篇关于使用CasperJS进行Web抓取会返回未记录的奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆