How to use NodeJS / PhantomJS / CasperJS on Windows 7

一个人想着一个人 提交于 2019-12-04 19:26:16
Randomius

After you install PhantomJS do next:

  1. From the Desktop, right-click My Computer and click Properties.
  2. Click Advanced System Settings link in the left column.
  3. In the System Properties window click the Environment Variables button.
  4. Find PATH variable and click Edit
  5. Add PhantomJS path at the end of the variable value (don't forget ; before it)

For now you can use phantomjs from your CMD. Ex.: phantomjs c:\mywebsite\with\ajax\dopescript.js

After these steps download CasperJS and put it in PhantomJS folder

Ex.: c:\phantomjs\casperjs

Do previous steps for PATH variable for CasperJS (plus \bin at the end)

Ex.: c:\phantomjs\casperjs\bin

Try casperjs from CMD.

If it's not working go to batchbin directory in casperjs folder and lunch casperjs.bat

Now try to call CasperJs from this folder. (Works for me)

So for now you should have PhantomJS + CasperJS.

About saving results:

Put this var fs = require('fs'); at the beginning of your script and call

fs.write('result.html', myData); where myData is data that you need to save.

Here is more information about FS: PhantomJS File System

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!