You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Web-Search/quickstarts/csharp.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,17 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: bing-web-search
10
10
ms.topic: quickstart
11
-
ms.date: 12/09/2019
11
+
ms.date: 05/20/2020
12
12
ms.author: aahi
13
13
ms.custom: seodec2018
14
14
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using C#.
15
15
---
16
16
17
17
# Quickstart: Search the web using the Bing Web Search REST API and C#
18
18
19
-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This C# application sends a search request to the API, and shows the response. While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
19
+
Use this quickstart to make your first call to the Bing Web Search API. This C# application sends a search request to the API, and shows the JSON response. Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
20
+
21
+
This example program only uses .NET Core classes.
20
22
21
23
## Prerequisites
22
24
@@ -26,13 +28,11 @@ Here are a few things that you'll need before running this quickstart:
A few variables must be set before we can continue. `uriBase`can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that the `uriBase` is valid and replace the `accessKey` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `searchTerm`. Remember to add this code to the `Program` class as noted above.
61
+
A few variables must be set before we can continue. You can use the value of `uriBase`in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that `uriBase` is valid and replace the `accessKey` value with a valid subscription key from your Azure account. You can customize the search query by replacing the value for `searchTerm`. Add this code to the `Program` class as noted in the previous section.
The `Main()` method is required and it's the first method invoked when the program is started. In this application, the main method validates the `accessKey`, makes a request, and prints the response.
77
+
The `Main()` method is required and is the first method invoked when you start the program. In this application, the main method validates the `accessKey`, makes a request, and prints the response.
78
78
79
79
Keep in mind that `main()` is dependent on methods that are created in the next few sections.
The last step is to run your code! If you'd like to compare your code with ours, [sample code is available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingWebSearchv7.cs).
234
+
The last step is to run your code. If you'd like to compare your code with ours, see the [sample code on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingWebSearchv7.cs).
235
235
236
-
## Sample response
236
+
## Example JSON response
237
237
238
238
Responses from the Bing Web Search API are returned as JSON. This sample response has been truncated to show a single result.
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using Java.
15
15
---
16
16
17
17
# Quickstart: Use Java to search the web with the Bing Web Search REST API, an Azure cognitive service
18
18
19
-
In this quickstart, you'll use a Java application to make your first call to the Bing Web Search API and receive the JSON response. This Java application sends a search request to the API, and shows the response. While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
19
+
In this quickstart, you'll use a Java application to make your first call to the Bing Web Search API. This Java application sends a search request to the API, and shows the JSON response. Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
20
20
21
21
## Prerequisites
22
22
@@ -57,7 +57,7 @@ If you're using Maven, declare Gson in the `POM.xml`. Skip this step if you've i
57
57
58
58
## Declare the BingWebSearch class
59
59
60
-
Declare the `BingWebSearch` class. It will include most of the code we review in this quickstart including the `main` method.
60
+
Declare the `BingWebSearch` class. It includes most of the code we review in this quickstart, including the `main()` method.
61
61
62
62
```java
63
63
publicclassBingWebSearch {
@@ -69,7 +69,7 @@ public class BingWebSearch {
69
69
70
70
## Define variables
71
71
72
-
This code sets the `subscriptionKey`, `host`, `path`, and `searchTerm`. `host`can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Replace the `subscriptionKey` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `searchTerm`. Remember to add this code to the `BingWebSearch` class as noted above.
72
+
This code sets the `subscriptionKey`, `host`, `path`, and `searchTerm`. You can use the value of `host`in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Replace the `subscriptionKey` value with a valid subscription key from your Azure account. You can customize the search query by replacing the value for `searchTerm`. Add this code to the `BingWebSearch` class as noted in the previous section.
This method, which lives in the `BingWebSearch` class, constructs the `url`, receives and parses the response, and extracts Bing-related HTTP headers.
90
+
This method, which is included in the `BingWebSearch` class, constructs the `url`, receives and parses the response, and extracts Bing-related HTTP headers.
@@ -133,7 +133,7 @@ public static String prettify(String json_text) {
133
133
134
134
## Declare the main method
135
135
136
-
This method is required and is the first method invoked when the program is started. In this application, it includes code that validates the `subscriptionKey`, makes a request, and prints the JSON response.
136
+
The `main()`method is required and is the first method invoked when you start the program. In this application, it includes code that validates the `subscriptionKey`, makes a request, and prints the JSON response.
137
137
138
138
```java
139
139
publicstaticvoid main (String[] args) {
@@ -178,7 +178,7 @@ class SearchResults{
178
178
179
179
## Put it all together
180
180
181
-
The last step is to compile your code and run it! Here are the commands:
181
+
The last step is to compile your code and run it. Use the following commands:
If you'd like to compare your code with ours, [sample code is available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingWebSearchv7.java).
189
189
190
-
## Sample response
190
+
## Example JSON response
191
191
192
192
Responses from the Bing Web Search API are returned as JSON. This sample response has been truncated to show a single result.
193
193
@@ -316,6 +316,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
316
316
## Next steps
317
317
318
318
> [!div class="nextstepaction"]
319
-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
319
+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Web-Search/quickstarts/nodejs.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: bing-web-search
10
10
ms.topic: quickstart
11
-
ms.date: 12/09/2019
11
+
ms.date: 05/20/2020
12
12
ms.author: aahi
13
13
ms.custom: seodec2018
14
14
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using Node.js.
15
15
---
16
16
17
17
# Quickstart: Search the web using the Bing Web Search REST API and Node.js
18
18
19
-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This Node.js application sends a search request to the API, and shows the response. While this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
19
+
Use this quickstart to make your first call to the Bing Web Search API. This Node.js application sends a search request to the API, and shows the JSON response. Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
20
20
21
21
## Prerequisites
22
22
@@ -29,8 +29,7 @@ Here are a few things that you'll need before running this quickstart:
29
29
30
30
## Create a project and declare required modules
31
31
32
-
Create a new Node.js project in your favorite IDE or editor.
33
-
Then copy the code snippet below into your project in a file named `search.js`.
32
+
Create a new Node.js project in your favorite IDE or editor. Then, copy the following code snippet to your project in a file named `search.js`:
34
33
35
34
```javascript
36
35
// Use this simple app to query the Bing Web Search API and get a JSON response.
@@ -40,9 +39,9 @@ const https = require('https')
40
39
41
40
## Set the subscription key
42
41
43
-
This code snippet uses the `AZURE_SUBSCRIPTION_KEY` environment variable to store your subscription key, a good practice to prevent the accidental exposure of your keys when deploying code. Go to the [Your APIs page](https://azure.microsoft.com/try/cognitive-services/my-apis/?apiSlug=search-api-v7) to look up your subscription key.
42
+
This code snippet uses the `AZURE_SUBSCRIPTION_KEY` environment variable to store your subscription key, which is a good practice to prevent the accidental exposure of your keys when deploying code. To look up your subscription key, see [Your APIs](https://azure.microsoft.com/try/cognitive-services/my-apis/?apiSlug=search-api-v7).
44
43
45
-
If you're unfamiliar with using environment variables, or looking to run this app as fast as possible, then you can replace `process.env['AZURE_SUBSCRIPTION_KEY']` with your subscription key set as a string.
44
+
If you're unfamiliar with the use of environment variables, or you want to run this app as fast as possible, replace `process.env['AZURE_SUBSCRIPTION_KEY']` with your subscription key set as a string.
This function will make a secure GET request, saving the search query as a query parameter in the path. `hostname` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. `encodeURIComponent` is used to escape invalid characters, and the subscription key is passed in a header. The callback receives a [response](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_serverresponse) that subscribes to the `data` event to aggregate the JSON body, the `error` event to log any issues, and the `end` event to know when the message should be considered complete. When complete, the app will print the interesting headers and message body. You can play with the colors and set the depth to suit your preference, a depth of `1` gives a nice summary of the response.
55
+
This function makes a secure GET request and saves the search query as a query parameter in the path. You can use the value of `hostname` in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
56
+
57
+
In this function, `encodeURIComponent` is used to escape invalid characters, and the subscription key is passed in a header. The callback receives a [response](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_serverresponse) that subscribes to the `data` event to aggregate the JSON body, the `error` event to log any issues, and the `end` event to know when the message should be considered complete. When complete, the app prints the interesting headers and message body. You can adjust the colors and set the depth to suit your preference. A depth of `1` gives a nice summary of the response.
57
58
58
59
```javascript
59
60
functionbingWebSearch(query) {
@@ -83,15 +84,15 @@ function bingWebSearch(query) {
83
84
84
85
## Get the query
85
86
86
-
Let's look at the program's arguments to find the query. The first argument is the path to node, the second is our filename, and the third is your query. If the query is absent, a default query of "Microsoft Cognitive Services" is used.
87
+
Let's look at the program's arguments to find the query. The first argument is the path to the node, the second is our filename, and the third is your query. If the query is absent, a default query of "Microsoft Cognitive Services" is used.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Web-Search/quickstarts/python.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: bing-web-search
10
10
ms.topic: quickstart
11
-
ms.date: 12/09/2019
11
+
ms.date: 05/20/2020
12
12
ms.author: aahi
13
13
ms.custom: seodec2018
14
14
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using Python.
15
15
---
16
16
17
17
# Quickstart: Use Python to call the Bing Web Search API
18
18
19
-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This Python application sends a search request to the API, and shows the response. While this application is written in Python, the API is a RESTful Web service compatible with most programming languages.
19
+
Use this quickstart to make your first call to the Bing Web Search API. This Python application sends a search request to the API, and shows the JSON response. Although this application is written in Python, the API is a RESTful Web service compatible with most programming languages.
20
20
21
21
This example is run as a Jupyter notebook on [MyBinder](https://mybinder.org). Select the launch binder badge:
22
22
@@ -30,28 +30,30 @@ This example is run as a Jupyter notebook on [MyBinder](https://mybinder.org). S
30
30
31
31
## Define variables
32
32
33
-
Replace the `subscription_key` value with a valid subscription key from your Azure account.
33
+
1.Replace the `subscription_key` value with a valid subscription key from your Azure account.
34
34
35
-
```python
36
-
subscription_key ="YOUR_ACCESS_KEY"
37
-
assert subscription_key
38
-
```
35
+
```python
36
+
subscription_key ="YOUR_ACCESS_KEY"
37
+
assert subscription_key
38
+
```
39
39
40
-
Declare the Bing Web Search API endpoint. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
40
+
2.Declare the Bing Web Search API endpoint. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
Feel free to customize the search query by replacing the value for `search_term`.
46
+
3. Optionally, customize the search query by replacing the value for `search_term`.
47
47
48
-
```python
49
-
search_term ="Azure Cognitive Services"
50
-
```
48
+
```python
49
+
search_term ="Azure Cognitive Services"
50
+
```
51
51
52
52
## Make a request
53
53
54
-
This block uses the `requests` library to call the Bing Web Search API and return the results as a JSON object. The API key is passed in the `headers` dictionary, and the search term and query parameters are passed in the `params` dictionary. See [Bing Web Search API v7](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-web-api-v7-reference) documentation for a complete list of options and parameters.
54
+
This code uses the `requests` library to call the Bing Web Search API and return the results as a JSON object. The API key is passed in the `headers` dictionary, and the search term and query parameters are passed in the `params` dictionary.
55
+
56
+
For a complete list of options and parameters, see [Bing Web Search API v7](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-web-api-v7-reference).
The `search_results` object includes the search results and metadata like related queries and pages. This code uses the `IPython.display` library to format and display the response in your browser.
70
+
The `search_results` object includes the search results and metadata such as related queries and pages. This code uses the `IPython.display` library to format and display the response in your browser.
If you'd like to run this code locally, the complete [sample is available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/python/Search/BingWebSearchv7.py).
85
+
To run this code locally, see the complete [sample available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/python/Search/BingWebSearchv7.py).
0 commit comments