How to do it

We proceed with the recipe as follows:

  1. The code to perform the scraping is in the script file, 08/02_geocode_wikipedia_edits.py. Running the script produces the following output (truncated to the first few geo IPs):
Reading page: https://en.wikipedia.org/w/index.php?title=Web_scraping&offset=&limit=500&action=historyGot 106 ip addresses{'ip': '2601:647:4a04:86d0:1cdf:8f8a:5ca5:76a0', 'country_code': 'US', 'country_name': 'United States', 'region_code': 'CA', 'region_name': 'California', 'city': 'Sunnyvale', 'zip_code': '94085', 'time_zone': 'America/Los_Angeles', 'latitude': 37.3887, 'longitude': -122.0188, 'metro_code': 807}{'ip': '194.171.56.13', 'country_code': 'NL', 'country_name': 'Netherlands', 'region_code': '', 'region_name': ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.