Hi so I'm trying to write a webcrawler type script in PhantomJS.
Here is the code:
var page = require('webpage').create();
page.onCallback = function() {
page.render('snapshot.png');
phantom.exit();
};
page.open('http://somesitewithangularscripts.com');
However it keeps on giving me the error:
ReferenceError: Can't find variable: angular
From what I read online I need to tell phantom where the angular library is on my local machine? But I can't find any guides/docs/tutorials on how to do that.
By the way I'm running everything via an npm framework on my machine.
PhantomJs version: 1.9.8
Error msg:
Unable to load resource (#19URL:https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#22URL:https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#39URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#40URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular-sanitize.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#41URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular-animate.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#42URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular-route.min.js)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#43URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular-cookies.min.js)
Error code: 6. Description: SSL handshake failed
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/ngModules.js?nu5xd5: 63
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/ngModules.js?nu5xd5: 66
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/sites/all/libraries/angular-truncate/src/truncate.js?nu5xd5: 1
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/sites/all/libraries/angular-timer/angular-timer.min.js?nu5xd5: 8
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/esportsDirectives.js?nu5xd5: 8
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/filters/esportsFilters.js?nu5xd5: 3
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/esportsServices.js?nu5xd5: 8
ERROR: ReferenceError: Can't find variable: angular
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/js/esportsApp.js?nu5xd5: 8
ERROR: TypeError: 'undefined' is not an object (evaluating 'esportsDirectives.controller')
TRACE:
-> http://na.lolesports.com/profiles/lolesports_profile/modules/custom/esports/esports_directives/js/controllers/MatchController.js?nu5xd5: 6
Unable to load resource (#111URL:https://cdn.leagueoflegends.com/riotbar/prod/1.5.2/images/bar/bg-bar.jpg?1435084967)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#112URL:https://cdn.leagueoflegends.com/riotbar/prod/1.5.2/images/bar/icon-game-lol.png?1435084967)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#113URL:https://cdn.leagueoflegends.com/riotbar/prod/1.5.2/images/account/sprites-sacb8a8a753.png)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#114URL:https://cdn.leagueoflegends.com/riotbar/prod/1.5.2/images/bar/dropdown-trigger-blue.png?1435084967)
Error code: 6. Description: SSL handshake failed
Unable to load resource (#152URL:https://stats.g.doubleclick.net/r/collect?t=dc&aip=1&_r=3&v=1&_v=j38&tid=UA-37673467-1&cid=123674724.1441623986&jid=1834200343&_u=SGAAgAQi~&z=790116041)
Error code: 6. Description: SSL handshake failed
CONSOLE: Unsafe JavaScript attempt to access frame with URL http://tpc.googlesyndication.com/safeframe/1-0-2/html/container.html from frame with URL http://na.lolesports.com/na-lcs/2015/spring/matches/week-1/team-solomid-vs-cloud9. Domains, protocols and ports must match.
(from line #undefined in "undefined")
CONSOLE: Unsafe JavaScript attempt to access frame with URL http://tpc.googlesyndication.com/safeframe/1-0-2/html/container.html from frame with URL http://na.lolesports.com/na-lcs/2015/spring/matches/week-1/team-solomid-vs-cloud9. Domains, protocols and ports must match.
(from line #undefined in "undefined")
CONSOLE: Unsafe JavaScript attempt to access frame with URL http://tpc.googlesyndication.com/safeframe/1-0-2/html/container.html from frame with URL http://na.lolesports.com/na-lcs/2015/spring/matches/week-1/team-solomid-vs-cloud9. Domains, protocols and ports must match.
(from line #undefined in "undefined")
Unable to load resource (#153URL:https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js)
Error code: 6. Description: SSL handshake failed