-
-
Save yaph/4226995 to your computer and use it in GitHub Desktop.
Search where people are moving in Germany
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# requires: pattern http://www.clips.ua.ac.be/pages/pattern | |
from pattern.web import * | |
import csv | |
import itertools | |
# engine = Google(license='XXX', throttle=2.0) | |
#engine = Twitter(license=None) | |
engine = Bing() | |
phrase = '"von %s nach %s gezogen"' | |
cities = ["Berlin", "Hamburg", "München", "Köln", "Frankfurt am Main", "Stuttgart", "Düsseldorf", "Dortmund", "Essen", "Bremen", "Leipzig", "Dresden", "Hannover", "Nürnberg", "Duisburg", "Bochum", "Wuppertal", "Bonn", "Bielefeld", "Mannheim", "Karlsruhe", "Münster", "Wiesbaden", "Augsburg", "Aachen", "Mönchengladbach", "Gelsenkirchen", "Braunschweig", "Chemnitz", "Kiel"] | |
csv_writer = csv.writer(open('cities.csv', 'wb'), quoting=csv.QUOTE_NONNUMERIC) | |
csv_writer.writerow(["Source", "Target", "Weight"]) | |
for i, j in itertools.combinations(cities, 2): | |
results = engine.search(phrase % (i,j), type=SEARCH) | |
csv_writer.writerow([i, j, results.total]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment