# Search

The `bing_search` source is designed to retrieve Bing Search results pages (SERPs).

{% hint style="info" %}
To scrape **AI-generated search results** from Bing, use the `render` parameter.
{% endhint %}

## Request samples

In the example below, we make a request to retrieve Bing search results for the search term `adidas`. The search will start from the 11th page and retrieve 10 pages of results, which will be delivered in a structured format.

{% tabs %}
{% tab title="cURL" %}

```shell
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "bing_search",
        "domain": "com",
        "query": "adidas",
        "start_page": 11,
        "pages": 10,
        "callback_url": "https://your.callback.url",
        "parse": true
    }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# Structure payload.
payload = {
    'source': 'bing_search',
    'domain': 'com',
    'query': 'adidas',
    'start_page': 11,
    'pages': 10,
    'callback_url': 'https://your.callback.url',
    'parse': True
}

# Get response.
response = requests.request(
    'POST',
    'https://realtime.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require("https");

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "bing_search",
    domain: "com",
    query: "adidas",
    start_page: 11,
    pages: 10,
    callback_url: "https://your.callback.url",
    parse: true,
};

const options = {
    hostname: "realtime.oxylabs.io",
    path: "/v1/queries",
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization:
            "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
    },
};

const request = https.request(options, (response) => {
    let data = "";

    response.on("data", (chunk) => {
        data += chunk;
    });

    response.on("end", () => {
        const responseData = JSON.parse(data);
        console.log(JSON.stringify(responseData, null, 2));
    });
});

request.on("error", (error) => {
    console.error("Error:", error);
});

request.write(JSON.stringify(body));
request.end();
```

{% endtab %}

{% tab title="HTTP" %}

```http
https://realtime.oxylabs.io/v1/queries?source=bing_search&domain=com&query=adidas&start_page=11&pages=10&parse=true&access_token=12345abcdep
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'bing_search',
    'domain' => 'com',
    'query' => 'adidas',
    'start_page' => 11,
    'pages' => 10,
    'callback_url' => 'https://your.callback.url',
    'parse' => true
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME" . ":" . "PASSWORD");

$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	const Username = "USERNAME"
	const Password = "PASSWORD"

	payload := map[string]interface{}{
		"source":       "bing_search",
		"domain":       "com",
		"query":        "adidas",
		"start_page":   11,
		"pages":        10,
		"callback_url": "https://your.callback.url",
		"parse":        true,
	}

	jsonValue, _ := json.Marshal(payload)

	client := &http.Client{}
	request, _ := http.NewRequest("POST",
		"https://realtime.oxylabs.io/v1/queries",
		bytes.NewBuffer(jsonValue),
	)

	request.SetBasicAuth(Username, Password)
	response, _ := client.Do(request)

	responseText, _ := ioutil.ReadAll(response.Body)
	fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "USERNAME";
            const string Password = "PASSWORD";

            var parameters = new {
                source = "bing_search",
                domain = "com",
                query = "adidas",
                start_page = 11,
                pages = 10,
                callback_url = "https://your.callback.url",
                parse = true
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://realtime.oxylabs.io");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
            requestMessage.Content = JsonContent.Create(parameters);

            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import org.json.JSONObject;
import java.util.concurrent.TimeUnit;

public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "USERNAME";
    public static final String PASSWORD = "PASSWORD";

    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "bing_search");
        jsonObject.put("domain", "com");
        jsonObject.put("query", "adidas");
        jsonObject.put("start_page", 11);
        jsonObject.put("pages", 10);
        jsonObject.put("callback_url", "https://your.callback.url");
        jsonObject.put("parse", true);

        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };

        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .readTimeout(180, TimeUnit.SECONDS)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://realtime.oxylabs.io/v1/queries")
                .post(body)
                .build();

        try (var response = client.newCall(request).execute()) {
            if (response.body() != null) {
                try (var responseBody = response.body()) {
                    System.out.println(responseBody.string());
                }
            }
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }

        System.exit(0);
    }

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
    "source": "bing_search",
    "domain": "com",
    "query": "adidas",
    "start_page": 11,
    "pages": 10,
    "callback_url": "https://your.callback.url",
    "parse": true
}
```

{% endtab %}
{% endtabs %}

We use synchronous [**Realtime**](https://developers.oxylabs.io/scraping-solutions/web-scraper-api/integration-methods/realtime) integration method in our examples. If you would like to use [**Proxy Endpoint**](https://developers.oxylabs.io/scraping-solutions/web-scraper-api/integration-methods/proxy-endpoint) or asynchronous [**Push-Pull**](https://developers.oxylabs.io/scraping-solutions/web-scraper-api/integration-methods/push-pull) integration, refer to the [**integration methods**](https://developers.oxylabs.io/scraping-solutions/web-scraper-api/integration-methods) section.

In the following example, we send a request to retrieve AI-generated Bing search results for the search term `best seo tools`.

```json
{
    "source": "bing_search", 
    "query": "best seo tools", 
    "render": "html"
}
```

## Request parameter values

### Generic

Basic setup and customization options for Bing search scraping.

<table><thead><tr><th width="222">Parameter</th><th width="350.3333333333333">Description</th><th>Default Value</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong>source</strong></mark></td><td>Sets the scraper.</td><td><code>bing_search</code></td></tr><tr><td><mark style="background-color:green;"><strong>query</strong></mark></td><td>The keyword or phrase to search for.</td><td>-</td></tr><tr><td><code>render</code></td><td>Enables JavaScript rendering when set to <code>html</code>. <a href="../../features/js-rendering-and-browser-control/javascript-rendering"><strong>More info</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>parse</code></td><td>Returns parsed data when set to <code>true</code>. Explore output <a href="#output-data-dictionary"><strong>data dictionary</strong></a>.</td><td><code>false</code></td></tr><tr><td><code>callback_url</code></td><td>URL to your callback endpoint. <a href="../../../integration-methods/push-pull#callback"><strong>More info</strong></a>.</td><td>-</td></tr><tr><td><code>user_agent_type</code></td><td>Device type and browser. The full list can be found <a href="../../features/http-context-and-job-management/user-agent-type"><strong>here</strong></a>.</td><td><code>desktop</code></td></tr></tbody></table>

&#x20;    \- mandatory parameter

### Localization

Adapt search results to specific geographical locations, domains, and languages.

<table><thead><tr><th width="222">Parameter</th><th width="350.3333333333333">Description</th><th>Default Value</th></tr></thead><tbody><tr><td><code>geo_location</code></td><td>Specifies the location for search results. Supports city, state, country, or coordinate formats. <a href="../../../features/localization/serp-localization#bing"><strong>Read more</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>domain</code></td><td>Localize results for a certain country. Valid values: <code>com</code>, <code>ru</code>, <code>ua</code>, <code>by</code>, <code>kz</code>, <code>tr</code>.</td><td><code>com</code></td></tr><tr><td><code>locale</code></td><td><code>Accept-Language</code> header value which changes your Bing search page web interface language. <a href="../../../features/localization/domain-locale-results-language#bing"><strong>More info</strong></a>.</td><td>-</td></tr></tbody></table>

### Pagination

Controls for managing the pagination and retrieval of search results.

<table><thead><tr><th width="222">Parameter</th><th width="350.3333333333333">Description</th><th width="167">Default Value</th></tr></thead><tbody><tr><td><code>start_page</code></td><td>Starting page number.</td><td><code>1</code></td></tr><tr><td><code>pages</code></td><td>Number of pages to retrieve.</td><td><code>1</code></td></tr><tr><td><code>limit</code></td><td>Number of results to retrieve in each page.</td><td><code>10</code></td></tr></tbody></table>

## Structured data

SERP Scraper API is capable of extracting either an HTML or JSON object that contains Bing search results, offering structured data on various elements of the results page.

{% file src="<https://63892162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FKswWxZOf6XzVtJJ7lFvH%2FBing.json?alt=media&token=c4faae6f-4192-4bd8-8b42-4194c0447853>" %}

## Output data dictionary

#### **HTML example**

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXek9v-EPIfkuBe9agDrGzoz2gQspI2bjipHUUGSl2Y7sW1NB1ZBUSTdAlG-VzFcG0m-Anei0qj3E4b4h_N-RgJhrHSaqFDF8WvVIXaJLOodVj_mxmnRtIh9e9ViRaxZrQhhL3Ntd9dARaGg-px-j0xQVYU?key=NG4r24r-hbhCkjE_d7r1ZQ" alt="" width="563"><figcaption></figcaption></figure>

#### JSON structure

The table below presents a detailed list of each SERP feature we parse, along with its description and data type. The table also includes some metadata.

<table><thead><tr><th width="233">Key</th><th width="366">Description</th><th>Type</th></tr></thead><tbody><tr><td><code>url</code></td><td>The URL of the Bing search page.</td><td>string</td></tr><tr><td><code>page</code></td><td>The current page number.</td><td>integer</td></tr><tr><td><code>results</code></td><td>A dictionary containing the results of the search.</td><td>object</td></tr><tr><td><code>paid</code> (optional)</td><td>A list of sponsored results with their respective details.</td><td>array</td></tr><tr><td><code>organic</code></td><td>A list of unpaid listings with their respective details.</td><td>array</td></tr><tr><td><code>parse_status_code</code></td><td>The status code of the parsing job. You can see the parser status codes described <a href="https://github.com/oxylabs/gitbook-public-english/blob/master/scraping-solutions/web-scraper-api/targets/bing/broken-reference/README.md"><strong>here</strong></a>.</td><td>integer</td></tr><tr><td><code>created_at</code></td><td>The timestamp when the scraping job was created.</td><td>timestamp</td></tr><tr><td><code>updated_at</code></td><td>The timestamp when the scraping job was finished.</td><td>timestamp</td></tr><tr><td><code>status_code</code></td><td>The status code of the scraping job. You can see the scraper status codes described <a href="https://github.com/oxylabs/gitbook-public-english/blob/master/scraping-solutions/web-scraper-api/targets/bing/broken-reference/README.md"><strong>here</strong></a>.</td><td>integer</td></tr><tr><td><code>job_id</code></td><td>The ID of the job associated with the scraping job.</td><td>string</td></tr></tbody></table>

{% hint style="info" %}
In the following sections, parsed JSON code snippets are shortened where more than one item for the result type is available.
{% endhint %}

### Paid

<figure><img src="https://63892162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FVScD3znLScPcnpkdaG84%2Fbing_search.png?alt=media&#x26;token=daec195c-885c-4714-ac0a-1e1c09c92a44" alt=""><figcaption></figcaption></figure>

```json
...
  "paid": [
    {
        "pos": 1,
        "url": "https://www.bing.com/aclick?ld=e8TB2-TOVbuwbSri4984NcRjVUCUyQghxnzejHV59xXn6r9lgz7ciPH0EL82ftdUCMBGEyAqiFGOiPXPkAOfdD7Y-Xpb6_pZlMPNZ2x6tTn4WAr8KA0oPNQYW031wP0d8g-pQsdx7BmXEN9ZojHVTY7Jznw7BafmzDSQCtL-MgYN9BRUmeBp74Eo3wYCJfbPIT_cWI2g&u=aHR0cCUzYSUyZiUyZnd3dy5yZW1pc2VzZW5saWduZS5mciUyZmJhc2tldC1uaWtlLWpvcmRhbiUzZnRhcmdldGlkJTNka3dkLTg1MTQ0NzUwMTM5NzExJTI2bWF0Y2h0eXBlJTNkcCUyNmRldmljZSUzZGMlMjZjYW1wYWlnbmlkJTNkNTMxMzY2ODQ3JTI2Y3JlYXRpdmUlM2QlMjZhZGdyb3VwaWQlM2QxMzYyMjk3NDM4ODkzNDg1JTI2ZmVlZGl0ZW1pZCUzZCUyNmxvY19waHlzaWNhbF9tcyUzZDE0MzAyNyUyNmxvY19pbnRlcmVzdF9tcyUzZCUyNm5ldHdvcmslM2RvJTI2ZGV2aWNlbW9kZWwlM2QlMjZwbGFjZW1lbnQlM2QlMjZrZXl3b3JkJTNkJTI0YmFza2V0JTI1MjBuaWtlJTI1MjBqb3JkYW4lMjZ0YXJnZXQlM2QlMjZhZHBvc2l0aW9uJTNkJTI2dHJhY2tpZCUzZGZyX2FsbF9kZWFsc18yX2JpbmclMjZtSWQlM2RIMTQ5MDAzQ1FOJTI2bXNjbGtpZCUzZDc5NjY4ODI4MDQ0ODE2NjVjNTJmZWU0MTc4Yjk1NWJm&rlid=7966882804481665c52fee4178b955bf",
        "desc": "Neue Releases, Retro-Klassiker & zeitlose Ikonen. Entdecke Air Jordan bei Nike. Meistere das Spiel und erlebe Tradition neu mit Air Jordan von Nike.",
        "title": "Offizielle Air Jordan Webseite | Shoppe Nike Jumpman-Produkte",
        "url_shown": "www.nike.com/air/jordan",
        "pos_overall": 11
    },
    {
        "pos": 2,
        "url": "https://www.bing.com/aclick?ld=e8OBM60EyxdN2Qxvp-arD9JzVUCUwier4bXHLFD_dsME5lB1Pg9YnfVggGJSi3ORhgEF-Gwzqx3PiuxHd6fxx0MXN6JKmkwjaGnD2ROEo6W3eTA9fAn8bfi9vpeZ8xEeTyyq8sKhHcKj58HK6h9JnOT7G7zLTYg6MFHaWaGo06uKP4G58bRvFt98DUBKhWj8fd_L867A&u=aHR0cHMlM2ElMmYlMmZ3d3cuYW1hem9uLmNvbSUyZnMlMmYlM2ZpZSUzZFVURjglMjZrZXl3b3JkcyUzZHdvbWVuJTI1MjdzJTJiYWlyJTJiam9yZGFuJTJicmV0cm8lMmIxJTJiZWxldmF0ZSUyYmxvdyUyYmNhc3VhbCUyYnNob2VzJTI2aW5kZXglM2RhcHMlMjZ0YWclM2RtaDBiLTIwJTI2cmVmJTNkcGRfc2xfM2ltOXJscjRkb19iJTI2YWRncnBpZCUzZDEzMzkyMDc1NjMwMTkxMTIlMjZodmFkaWQlM2Q4MzcwMDczNjAyNTQ5NiUyNmh2bmV0dyUzZG8lMjZodnFtdCUzZGIlMjZodmJtdCUzZGJiJTI2aHZkZXYlM2RjJTI2aHZsb2NpbnQlM2QlMjZodmxvY3BoeSUzZDE0MzAyNyUyNmh2dGFyZ2lkJTNka3dkLTgzNzAxNTIzNzAwNjc0JTI2aHlkYWRjciUzZDgwNDJfMTM0Njc2MjQlMjZtc2Nsa2lkJTNkMTg4YzJhMmJhNzg0MWE2MWExY2M0YzQyZGI3NWJhMTU&rlid=188c2a2ba7841a61a1cc4c42db75ba15",
        "desc": "Sneakers und Mehr bei Foot Locker Online. Premium Kollektionen und Bekleidung!",
        "title": "Jordan - Foot Locker Germany | Foot Locker Germany",
        "url_shown": "www.footlocker.de",
        "pos_overall": 12
    }
],
...
```

<table><thead><tr><th width="169">Key (paid)</th><th width="387">Description</th><th>Type</th></tr></thead><tbody><tr><td><code>pos</code></td><td>The position of the advertisement within the list of paid ads.</td><td>integer</td></tr><tr><td><code>url</code></td><td>The complete URL of the paid advertisement.</td><td>string</td></tr><tr><td><code>desc</code></td><td>A brief description or summary of the advertisement content.</td><td>string</td></tr><tr><td><code>title</code></td><td>The main headline or title of the advertisement.</td><td>string</td></tr><tr><td><code>url_shown</code></td><td>The simplified URL displayed to users.</td><td>string</td></tr><tr><td><code>pos_overall</code></td><td>The ad's rank among all search results, including both paid and organic listings.</td><td>integer</td></tr></tbody></table>

### Organic

<figure><img src="https://63892162-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2F87lEYdjpeUnM06yiulJN%2FScreenshot%202024-06-17%20at%2012.16.42.png?alt=media&#x26;token=7321a7ce-b980-4a33-9e3b-959f4a671727" alt="" width="563"><figcaption></figcaption></figure>

```json
...
"organic": [
    {
        "pos": 1,
        "url": "https://www.bing.com/ck/a?!&&p=dfe8ec2f6aa2c9deJmltdHM9MTcxODU4MjQwMCZpZ3VpZD0wNzdiZTI5My05ZWM4LTZkNWYtMDE0Ni1mNjMyOWZmMzZjMDEmaW5zaWQ9NTIwOA&ptn=3&ver=2&hsh=3&fclid=077be293-9ec8-6d5f-0146-f6329ff36c01&psq=nike+jordan+shoes&u=a1aHR0cHM6Ly93d3cubmlrZS5jb20vcGgvdy9qb3JkYW4tc2hvZXMtMzdlZWZ6eTdvaz9tc29ja2lkPTA3N2JlMjkzOWVjODZkNWYwMTQ2ZjYzMjlmZjM2YzAx&ntb=1",
        "desc": "WEBFind Jordan Shoes at Nike.com. Free delivery and returns on select orders.",
        "title": "Jordan Shoes. Nike PH",
        "url_shown": "https://www.nike.com/ph/w/jordan-shoes-37eefzy7ok",
        "pos_overall": 1
    },
...
```

<table><thead><tr><th width="209">Key (organic)</th><th width="384">Description</th><th>Type</th></tr></thead><tbody><tr><td><code>pos</code></td><td>The rank of the organic result within the list of organic search results.</td><td>integer</td></tr><tr><td><code>url</code></td><td>The complete URL of the organic search result.</td><td>string</td></tr><tr><td><code>desc</code></td><td>A brief description or summary of the organic search result content.</td><td>string</td></tr><tr><td><code>title</code></td><td>The main headline or title of the organic search result.</td><td>string</td></tr><tr><td><code>url_shown</code></td><td>The simplified URL displayed to users.</td><td>string</td></tr><tr><td><code>pos_overall</code></td><td>The organic result's rank among all search results, including both paid and organic listings.</td><td>integer</td></tr></tbody></table>
