简体   繁体   中英

Python web scraping of a geolocated website

I'm trying to web scrape a website that requests users to share their location so it adapts the contents to the clients' country.

To do so, when I visit the site with Firefox a browser's pop up is displayed asking for that permission.

When scraping with Python I open the website with urllib. Is there any way I can post or send my coordinates so I get the correct geolocated website?

Thanks.

BR,

d.

Manually sumbit your data by browsing the website. Then check your post requests in your browser's developer tools. Store that information in a dictionary like shown below with data .

data = { "text": text }

Then use that to make a post request. req=urllib2.Request(url,urllib.urlencode(data), headers)

And then get your response.

response = urllib2.urlopen(req).read()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM