Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/ipgeocode.js
164 views
1
// Give the estimated location based on the IP address.
2
3
cb = function (data) {
4
var loc = data.city;
5
if (data.region_name.length > 0)
6
loc = loc + ', ' + data.region_name;
7
console.log('IP address: ' + data.ip);
8
console.log('Estimated location: ' + loc);
9
phantom.exit();
10
};
11
12
var el = document.createElement('script');
13
el.src = 'http://freegeoip.net/json/?callback=cb';
14
document.body.appendChild(el);
15
16