Skip to content

Latest commit

 

History

History
73 lines (46 loc) · 3.21 KB

File metadata and controls

73 lines (46 loc) · 3.21 KB

Bing Search Python SDK Samples

These samples will show you how to get up and running using the Python SDKs for various Bing Search services. They'll cover a few rudimentary use cases and hopefully express best practices for interacting with the data from these APIs.

Features

This project framework provides examples for the following services:

We provide several meta-packages to help you install several packages at a time. Please note that meta-packages are only recommended for development purpose. It's recommended in production to always pin specific version of individual packages.

Getting Started

Prerequisites

  1. A cognitive services API key with which to authenticate the SDK's calls. Sign up here by navigating to the Search services and acquiring an API key. You can get a trial key for free which will expire after 30 days. To execute both samples, you need an EntitySearch key and a Bing WebSearch key.

Installation

  1. If you don't already have it, install Python.

    This sample (and the SDK) is compatible with Python 2.7, 3.3, 3.4, 3.5 and 3.6.

  2. We recommend that you use a virtual environment to run this example, but it's not mandatory. Install and initialize the virtual environment with:

    pip install virtualenv
    virtualenv mytestenv
    cd mytestenv
    source bin/activate     # Linux shell (Bash, ZSH, etc.) only
    ./scripts/activate      # PowerShell only
    ./scripts/activate.bat  # Windows CMD only
    

Quickstart

  1. Clone the repository.

    git clone https://github.com/Azure-Samples/bing-search-python.git
    
  2. Install the dependencies using pip.

    cd bing-search-python
    pip install -r requirements.txt
    
  3. Set up the environment variable ENTITYSEARCH_SUBSCRIPTION_KEY with your CS key if you want to execute EntitySearch tests.

  4. Set up the environment variable WEBSEARCH_SUBSCRIPTION_KEY with your CS key if you want to execute WebSearch tests.

Demo

A demo app is included to show how to use the project.

To run the complte demo, execute python example.py

To run each individual demo, point directly to the file:

  1. python samples/entity_search_samples.py
  2. python samples/web_search_samples.py

To see the code of each example, simply look at the examples in the Samples folder. They are written to be isolated in scope so that you can see only what you're interested in.

Resources