I am trying to scrape data from a site that requires my geolocation via PHP and CURL. Is there any way to include Geolocation into the CURL call?
Well, I think the first step is to investigate how the website expects the location info to be transmitted. Are latitude and longitude sent as parameters on an AJAX call? Are they expected to be stored in cookies or HTTP headers? You can probably use your favorite browser's developer mode/plugin to check for this.
If the site uses the W3C Geolocation API (navigator.geolocation
), then it's likely simply sending latitude and longitude coordinates (unless it's doing some reverse geocoding first using Google or a similar API). You can look-up and then hard code a particular lat/lon pair if that's always the info that you're looking for. If you want to update using your computer's current location, that will depend on your OS: on a Snow Leopard Mac you could use this cool bash script.
Geolocation does not use any specific HTTP request headers. Most likely, javascript in the site's UI stores this information as a cookie or uses as a part of request. I would run Wireshark while browsing the website or use FireBug to take a look at the raw HTTP request headers and replicate them.