4

I never use python. The only language I know is JavaScript. I use node to do web work and I kept reading about how casper.js can scrape webpages. so I was thinking I could use it like usual. Now I am at the point of installing it and I get 'python' is not recognized as an internal or external command, operable program or batch file. I know this means to put python on my path. I don't want to install python.

I use JavaScript why should I install python? I'm just confused that since casper.js has a js at the end I would think that it would rely on js and not python. so can you confirm if I really need to install python. I really don't want to deal with another language right now. Is it a simple process?

jack blank
  • 5,073
  • 7
  • 41
  • 73
  • 2
    I'm not a node.js user, but one thing is clear: [casper.js won't work in node.js](http://docs.casperjs.org/en/latest/faq.html#is-casperjs-a-node-js-library). – OnesimusUnbound Apr 04 '16 at 00:40
  • I installed phantom. so I should be good if I add Python to path? I could use phantom with node I think. phantomjs works for me, I tested it with a simple console. it's the python error that I'm up to. – jack blank Apr 04 '16 at 01:06

2 Answers2

1

Yes, casper.js requires Python: http://docs.casperjs.org/en/latest/installation.html

PhantomJS 1.9.1 or greater. Please read the installation instructions for PhantomJS

Python 2.6 or greater for casperjs in the bin/ directory

However, all your coding will be in JavaScript. You don't have to (and, in fact, cannot) write a CasperJS script in Python.

Community
  • 1
  • 1
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
1

Do you need python to use casper.js?

Yes.

If so, why?

CasperJS requires python because its devs chose to use python for its executable entrypoint and internal test runner.

There is discussion around removing the python dependency for the 2.0 release (shell scripts and node.js have both been proposed).


Also, just for clarity: CasperJS does not use node.js. The fact that node requires python is irrelevant. CasperJS is an interface to PhantomJS, which is a headless webkit driver that happens to be scriptable by javascript, but is not built on node.js.

From the Casper docs:

While CasperJS is installable via npm, it is not a node.js module and will not work with NodeJS out of the box. You cannot load casper by using require(‘casperjs’) in node.

pje
  • 21,801
  • 10
  • 54
  • 70
  • "You cannot load casper by using require(‘casperjs’) in node." ? Goto casperjs official website ( http://casperjs.org/) and take a look at the sample program , casperjs is loaded with require(‘casperjs’) . Could you explain what is meant here? – divine Feb 09 '18 at 14:31