Search code examples
javascriptweb-scrapinggeolocationphantomjscasperjs

How to change CasperJS geolocation for scraping?


I have install casperjs on my server (at location Singapore) from which I am trying to scrape a website which delivers different data for different location. I have tested script from my local network (at location India). It works fine but from my server it scrapes Singapore data.

Is it possible to configure either CasperJS or Server for my Local network (India)?


Solution

  • It depends how the website determines the location. PhantomJS/CasperJS doesn't support geo location. Any such information is probably determined by the website from by looking at the IP address of the requesting browser (yes, PhantomJS is simply a browser like any other).

    If you want the location to change, then you can either use a Proxy server from another country or configure the machine CasperJS runs on to use VPN to pass all traffic through another country. PhantomJS has some proxy commandline options which you can also use with CasperJS in the same way.