0

I'm doing some exercises with CasperJS and I'm stuck in a pretty simple exercise.

I don't know if bestbuy.com website blocks the connection in some way. I've tried some different websites and they just work fine.

The Title is not printed on the console and the phantomjs task doesn't exit from the task.

Here you have the simple script:

var casper = require('casper').create({
  verbose:true,
  logLevel:'debug',
  pageSettings:{
    loadImages: true,
    loadPlugins: false,
    userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
  }
});

var url = 'http://www.bestbuy.com/';

casper.start(url, function () {
  this.echo(this.getTitle());
});

casper.run();

Can somebody, please explain what is this happening?

Thanks :)

Rafa
  • 115
  • 1
  • 8

1 Answers1

0

For some reason it looks like bestbuy might be blocking your useragent.

This works for me:-

var casper = require('casper').create({
  verbose:true,
  logLevel:'debug'
});

var url = 'http://www.bestbuy.com/';

casper.start(url, function () {
  this.echo(this.getTitle());
});

casper.run();

This outputs the title correctly

enter image description here

Rippo
  • 22,117
  • 14
  • 78
  • 117