Use this quickstart to learn how to request search results from your Bing Custom Search instance. Although this application is written in Python, the Bing Custom Search API is a RESTful web service compatible with most programming languages. The source code for this sample is available on GitHub.
PrerequisitesStart using the Bing Custom Search API by creating one of the following Azure resources.
Bing Custom Search resourceCreate a new Python file in your favorite IDE or editor, and add the following import statements. Create variables for your subscription key, custom configuration ID, and search term.
import json
import requests
subscriptionKey = "YOUR-SUBSCRIPTION-KEY"
customConfigId = "YOUR-CUSTOM-CONFIG-ID"
searchTerm = "microsoft"
Construct the request URL by appending your search term to the q=
query parameter, and your search instance's custom configuration ID to the customconfig=
parameter. Separate the parameters with an ampersand (&
). You can use the global endpoint in the following code, or use the custom subdomain endpoint displayed in the Azure portal for your resource.
url = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search?' + 'q=' + searchTerm + '&' + 'customconfig=' + customConfigId
Send the request to your Bing Custom Search instance, and print the returned search results.
r = requests.get(url, headers={'Ocp-Apim-Subscription-Key': subscriptionKey})
print(r.text)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4