The explanation is as follows. The script begins by executing the following code:
if __name__ == "__main__": geo_ips = collect_geo_ips('Web_scraping', 500) for geo_ip in geo_ips: print(geo_ip) with open('geo_ips.json', 'w') as outfile: json.dump(geo_ips, outfile)
A call is made to collect_geo_ips which will request the page with the specified topic and up to 500 edits. These geo IPs are then printed to the console, and also written to the geo_ips.json file.
The code for collect_geo_ips is the following:
def collect_geo_ips(article_title, limit): ip_addresses = get_history_ips(article_title, limit) print("Got %s ip addresses" % len(ip_addresses)) geo_ips = get_geo_ips(ip_addresses) return geo_ips
This function first makes a call ...