I have run my canary headless locally, how can I run the example "extract-google-results.js", should I use node extract-google-results.js ?
Same issues. I have an error like:
node extract-google-results.js
show in console:
{ Error: connect ECONNREFUSED 127.0.0.1:9222
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9222 }
when running your command.
@Zhanweelee @vanloc0301 If you run node extract-google-results.js locally you also need at least a local Google Chrome browser running listening on the remote debugging port. E.g. on my Archlinux OS the Chrome binary is called google-chrome:
google-chrome --remote-debugging-port=9222
I'm using Chrome 60. AFIAR that's now stable. You can also run Chrome in headless mode (this won't show you the usual Chrome window):
google-chrome --remote-debugging-port=9222 --disable-gpu --headless
But running without headless mode is easier at the beginning for debugging. You can actually see in the browser windows what's happening.
For those on macOS, google-chrome won't exist in your PATH with a default Chrome install. You can set up an alias to get around this:
alias google-chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
And then @githubixx's commands should work.
also make sure you close all your open chrome windows and after that start chrome again with the remote flag --remote-debugging-port=9222
Also, in the latest release (or on master), chrome-launcher will take care of that for you, so you shouldn't need to start Chrome manually anymore
@FabioAntunes Can you explain must close all Chrome windows?
In mode:
google-chrome --remote-debugging-port=9222 --disable-gpu --headless
I don't need close all Chrome windows.
To run that example locally with
node extract-google-results.js
I made sure I had the following minimum requirements:
Node.js v7.6.0
Chrome v60
chromeless v1.1.0
and changed:
const chromeless = new Chromeless({ remote: true })
to:
const chromeless = new Chromeless()
And then it works real nice - returning an array of the first 10 search results. 馃憤
$ node extract-google-results.js
/Users/jonathan/Downloads/extract-google-results.js:3
async function run() {
^^^^^^^^SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
my node version is v6.11.2, please help...
@Zhanweelee async/await are not implemented in node v6.11.2
you must update node > 7.6.0
@vanloc0301 What I meant by closing all windows first, was if you have chrome already running, chromeless will run the test in a new tab, but since you haven't started chrome with the --remote-debugging-port=9222 flag you will get ECONNREFUSED
Most helpful comment
@Zhanweelee @vanloc0301 If you run
node extract-google-results.jslocally you also need at least a local Google Chrome browser running listening on the remote debugging port. E.g. on my Archlinux OS the Chrome binary is calledgoogle-chrome:I'm using Chrome 60. AFIAR that's now stable. You can also run Chrome in headless mode (this won't show you the usual Chrome window):
But running without headless mode is easier at the beginning for debugging. You can actually see in the browser windows what's happening.