Skip to content

Instantly share code, notes, and snippets.

@thilohuellmann
Last active July 17, 2018 14:19
Show Gist options
  • Save thilohuellmann/fb4b3a28de3be088969beed050dffea5 to your computer and use it in GitHub Desktop.
Save thilohuellmann/fb4b3a28de3be088969beed050dffea5 to your computer and use it in GitHub Desktop.
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