Last active
July 17, 2018 14:19
-
-
Save thilohuellmann/fb4b3a28de3be088969beed050dffea5 to your computer and use it in GitHub Desktop.
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
for name, company in zip(names, companies): # zip to loop over names and companies simultaneously | |
query = name + company | |
headers = {'Ocp-Apim-Subscription-Key': YOUR_API_KEY } | |
params = urllib.parse.urlencode({'q': query,'count': '2','mkt': 'de-DE'}) # returns top 2 (German) results | |
conn = http.client.HTTPSConnection('api.cognitive.microsoft.com') | |
conn.request("GET", "/bing/v5.0/search?%s" % params, "{body}", headers) | |
response = conn.getresponse() | |
data = response.read().decode('utf-8') | |
json_file = json.loads(data) | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment