How to change PhantomJS version - web-scraping

I am learning PhantomJS for scraping. I started to incorporate CasperJS. When I run CasperJS and the filename I get back
CasperJS needs PhantomJS v1.x
How do you change the PhantomJS version to use CasperJS? Is there an easier way to scrape a website that is heavy javascript?
I used cheerio and require but they only get static html.

This message is shown if you try to use PhantomJS 2.x with a CasperJS version <= 1.1-beta.
use different PhantomJS once
If you also have PhantomJS 1.x on your system, you can simply change the executable like this in the command prompt.
cmd.exe:
C:\path> set PHANTOMJS_EXECUTABLE=C:\path\to\phantomjs198.exe
C:\path> casperjs script.js
terminal:
$ export PHANTOMJS_EXECUTABLE=/path/to/phantomjs198
$ casperjs script.js
You can also use "phantomjs198" instead of "/path/to/phantomjs198" if it is in PATH.
Update CasperJS
The other way would be to use the CasperJS from the master branch on GitHub (docs). It works rather well in my experience and supports PhantomJS 2.x (and PhantomJS 1.x).

Related

Atom Javascript Console

I've tried to use Script and atom-js-console on atom but when I run code using script I get this message 'env: node: No such file or directory'. How can I get a console that works with running javascript code on atom.
I recommend you hook it up to a web but if you want it inside of the atom-editor itself then there are packages for running it inside of the atom editor it self. Note: These packages copy chromes"inspect" view so don't expect it to be very optimised.

Cannot use interpreters in Zeppelin

I just start using Zeppelin with Scala and R. I have got a problem with interpreters. I download zeppelin from https://zeppelin.apache.org/download.html. I use zeppelin-0.6.1-bin-all.tgz.
After setting up everything, I use Firefox to use Zeppelin by visiting http://localhost:8082. I also did Interpreter binding by clicking to Bind/Unbind interpreter and then click save button. However, when I use R or Spark, I have got an information:
Prefix not found.
When I try spark.r, I have got an information:
spark.r interpreter not found.
Image:

How can I use grunt to open Google Chrome and pass flags like --incognito?

I am using grunt-contrib-connect for a local dev server and want to write a task to launch google chrome after server starts. But want to pass following arguments to open it in insecure mode.
--args --disable-web-security --user-data-dir
I tried grunt-open to do that but didn't find any options to pass flags.
Any help is appreciated.
You should be able to use grunt-exec to do what you need. A configuration like this works for me:
grunt.config.init({
...
exec: {
chrome: {
cmd: '"C:/Program Files (x86)/Google/Chrome/Application/chrome" --incognito http://washingtonpost.com'
}
}
...
});
Note that, on Windows, quotes are required around the path to the executable. If you're fortunate enough to be using less annoying OS, you won't need them.

Let atom editor recognize external APIs

I'm trying to set up a python like environment with Atom-editor on a Linux machine.
I find the autocomplete-python package that uses jedi.
In the settings of the package I tried to add some python path where the APIs are (/usr/lib/python2.7/dist-packages/) but then the autocompletion doesn't recognize these libraries (for example the PyQt ones)
Am I missing something?
For anybody having the same issue please look here.
Basically everything should work out of the box, but if it does not -- try to configure path to python executable with which you have installed your external module. If it's still fails to complete -- try to configure extra path to python modules. (usually your site-packages directory)

How to debug a Meteor plugin file?

I've followed Meteor Doc to register a plug-in package.
Created a plug-in file in the package/plugin/ folder
Added a debugger; in that file.
ran $ meteor debug;
Problem: debugger; directive is ignored. How to debug the plug-in file?
Thx!
plugin/compile-atscript.js:
Plugin.registerSourceHandler(
'ats'
, function (compileStep) {
var source = compileStep.read().toString('utf8');
console.log('source: ' + source);
debugger;
console.log('compiled source: ' + source);
});
The Meteor tool runs build plugins in-process, so you just need to run it under the debugger. On Linux and Mac OS X, the launcher script supports a TOOL_NODE_FLAGS variable that can be used to pass arguments to the Node.js runtime to enable debugging. See the instructions for debugging the Meteor tool, although these are geared toward use with a git checkout of Meteor. A hacky shortcut:
METEOR_INSTALLATION=~/.meteor/packages/meteor-tool/$(meteor --long-version | sed -ne 's/^meteor-tool#//p')/mt-$(meteor --arch)
TOOL_NODE_FLAGS=$METEOR_INSTALLATION/dev_bundle/lib/node_modules/node-inspector/bin/node-debug.js $METEOR_INSTALLATION/meteor
(Note, using just meteor on the last line may not work because when the default version of the Meteor tool executes the proper version for the app, the debugger would be started a second time.)
On Windows, support for TOOL_NODE_FLAGS was added to the launcher script in Meteor 1.4.4. If the app is using an older version of Meteor, one could manually edit the launcher script. The commands to start debugging would look like:
set METEOR_INSTALLATION=%LOCALAPPDATA%\.meteor\packages\meteor-tool\TOOL_VERSION\mt-os.windows.x86_32
set TOOL_NODE_FLAGS=%METEOR_INSTALLATION%\dev_bundle\lib\node_modules\node-inspector\bin\node-debug.js
%METEOR_INSTALLATION%\meteor.bat
(Someone else is welcome to add copy-and-pasteable code to figure out the correct TOOL_VERSION!)
On macOS
Set Environment variable
export TOOL_NODE_FLAGS="--inspect-brk"
List env vars
printenv
Run meteor
meteor
Debugger will be listening and will get attached to Chrome dev tools on opening the Chrome Browser.

Resources