adding readme
This commit is contained in:
Родитель
97063bc1ca
Коммит
b66a1f0487
44
README.md
44
README.md
|
@ -1,14 +1,42 @@
|
|||
# Project
|
||||
# Azure SDK for Python
|
||||
|
||||
> This repo has been populated by an initial template to help get you started. Please
|
||||
> make sure to update the content to build a great experience for community-building.
|
||||
[![Python](https://img.shields.io/pypi/pyversions/azure-core.svg?maxAge=2592000)](https://pypi.python.org/pypi/azure/) [![Build Status](https://bingapis.visualstudio.com/BingApis/_apis/build/status/microsoft.bing-search-sdk-for-python?branchName=main)](https://bingapis.visualstudio.com/BingApis/_build/latest?definitionId=8&branchName=main)
|
||||
|
||||
This repository is for active development of the Bing Apis SDK for Python. For consumers of the SDK we recommend visiting our [public developer docs](https://docs.microsoft.com/en-us/bing/search-apis/).
|
||||
|
||||
## Getting started
|
||||
|
||||
To get started with a specific library, see the `README.md` file located in the library's project folder.
|
||||
|
||||
You can find service libraries in the `/sdk` directory.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* Python 2.7, or 3.5 or later is required to use this package.
|
||||
* [Bing Apis Account](https://aka.ms/bingapisignup).
|
||||
|
||||
|
||||
### Install the packages
|
||||
|
||||
You can find all dependencies in requirements.txt
|
||||
* [Autosuggest](https://pypi.org/project/microsoft-bing-autosuggest/).
|
||||
* [Custom Image Search](https://pypi.org/project/microsoft-bing-customimagesearch/).
|
||||
* [Custom Web Search](https://pypi.org/project/microsoft-bing-customwebsearch/).
|
||||
* [Entity Search](https://pypi.org/project/microsoft-bing-entitysearch/).
|
||||
* [Image Search](https://pypi.org/project/microsoft-bing-imagesearch/).
|
||||
* [News Search](https://pypi.org/project/microsoft-bing-newssearch/).
|
||||
* [Spell Check](https://pypi.org/project/microsoft-bing-spellcheck/).
|
||||
* [Video Search](https://pypi.org/project/microsoft-bing-videosearch/).
|
||||
* [Visual Search](https://pypi.org/project/microsoft-bing-visualsearch/).
|
||||
* [Web Search](https://pypi.org/project/microsoft-bing-websearch/).
|
||||
* required packages: "msrest>=0.5.0", "msrestazure>=0.4.32,<2.0.0", "azure-common~=1.1"
|
||||
|
||||
## Need help?
|
||||
|
||||
* For detailed documentation visit our [Bing Apis for documentation](https://docs.microsoft.com/en-us/bing/search-apis/)
|
||||
* File an issue via [Github Issues](https://github.com/microsoft/bing-search-sdk-for-python/issues)
|
||||
|
||||
As the maintainer of this project, please make a few updates:
|
||||
|
||||
- Improving this README.MD file to provide a great experience
|
||||
- Updating SUPPORT.MD with content about this project's support experience
|
||||
- Understanding the security reporting process in SECURITY.MD
|
||||
- Remove this section from the README
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
microsoft-bing-websearch
|
||||
microsoft-bing-visualsearch
|
||||
microsoft-bing-videosearch
|
||||
microsoft-bing-imagesearch
|
||||
microsoft-bing-newssearch
|
||||
microsoft-bing-spellcheck
|
||||
microsoft-bing-entitysearch
|
||||
microsoft-bing-autosuggest
|
||||
microsoft-bing-customimagesearch
|
||||
microsoft-bing-customwebsearch
|
||||
msrest
|
||||
azure-common
|
||||
msrestazure
|
||||
azure-core
|
|
@ -10,7 +10,7 @@ from pprint import pprint
|
|||
|
||||
'''
|
||||
This sample uses the Bing Autosuggest API to check the spelling of query words and then suggests corrections.
|
||||
Bing Spell Check API: https://docs.microsoft.com/en-us/rest/api/cognitiveservices-bingsearch/bing-autosuggest-api-v7-reference57855119bca1df1c647bc358
|
||||
Bing Spell Check API: https://docs.microsoft.com/en-us/bing/search-apis/bing-spell-check/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Autosuggest subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -12,11 +12,10 @@ import requests
|
|||
|
||||
'''
|
||||
This sample uses the Bing Custom Search API to search for a query topic and get back user-controlled web page results.
|
||||
Bing Custom Search API: https://docs.microsoft.com/en-us/rest/api/cognitiveservices-bingsearch/bing-custom-search-api-v7-reference
|
||||
Bing Custom Search API: https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Custom Search subscription key and endpoint to your environment variables.
|
||||
# Your endpoint will have the form: https://<your-custom-subdomain>.cognitiveservices.azure.com
|
||||
subscriptionKey = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
|
||||
endpoint = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
|
||||
customConfigId = os.environ["BING_CUSTOM_CONFIG"] # you can also use "1"
|
||||
|
|
|
@ -6,7 +6,7 @@ import urllib.parse
|
|||
|
||||
'''
|
||||
This sample uses the Bing Entity Search v7 to search for restaurants and return details about it.
|
||||
Bing Entity Search API: https://westus2.dev.cognitive.microsoft.com/docs/services/7a3fb374be374859a823b79fd938cc65/operations/52069701a465405ab3286f82
|
||||
Bing Entity Search API: https://docs.microsoft.com/en-us/bing/search-apis/bing-entity-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Entity Search subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -10,7 +10,7 @@ import requests
|
|||
|
||||
'''
|
||||
This sample makes a call to the Bing Image Search API with a text query and returns relevant images with data.
|
||||
Documentation: https: // docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/
|
||||
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-image-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -10,7 +10,7 @@ import requests
|
|||
|
||||
'''
|
||||
This sample makes a call to the Bing News Search API with a text query and returns relevant news webpages.
|
||||
Documentation: https: // docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/
|
||||
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-news-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -10,7 +10,7 @@ import urllib.parse
|
|||
'''
|
||||
This sample uses the Bing Spell Check API to check the spelling of query words
|
||||
and then suggests corrections with a scored confidence.
|
||||
Bing Spell Check API: https://dev.cognitive.microsoft.com/docs/services/5f7d486e04d2430193e1ca8f760cd7ed/operations/57855119bca1df1c647bc358
|
||||
Bing Spell Check API: https://docs.microsoft.com/en-us/bing/search-apis/bing-spell-check/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Spell Check subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -10,7 +10,7 @@ import requests
|
|||
|
||||
'''
|
||||
This sample makes a call to the Bing Video Search API with a topic query and returns relevant video with data.
|
||||
Documentation: https: // docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/
|
||||
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-video-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
|
||||
|
|
|
@ -9,6 +9,7 @@ import requests
|
|||
'''
|
||||
This sample uses the Bing Visual Search API with a local, query image and returns several web links
|
||||
and data of the exact image and/or similar images.
|
||||
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-visual-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Search V7 subscriptionKey and endpoint to your environment variables.
|
||||
|
|
|
@ -8,12 +8,17 @@ import os
|
|||
from pprint import pprint
|
||||
import requests
|
||||
|
||||
'''
|
||||
This sample makes a call to the Bing Web Search API with a query and returns relevant web search.
|
||||
Documentation: https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/overview
|
||||
'''
|
||||
|
||||
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
|
||||
subscription_key = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
endpoint = os.environ['BING_SEARCH_V7_ENDPOINT'] + "/bing/v7.0/search"
|
||||
|
||||
# Query term(s) to search for.
|
||||
query = "Microsoft Cognitive Services"
|
||||
query = "Microsoft"
|
||||
|
||||
# Construct a request
|
||||
mkt = 'en-US'
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
---
|
||||
page_type: sample
|
||||
languages:
|
||||
- python
|
||||
products:
|
||||
- Bing Apis
|
||||
description: "These samples will show you how to get up and running using the Python SDKs."
|
||||
---
|
||||
|
||||
# Bing Apis Python SDK Samples
|
||||
|
||||
These samples will show you how to get up and running using the Python SDKs. 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:
|
||||
|
||||
|
||||
|
||||
### Language
|
||||
|
||||
* Using the **Bing Spell Check SDK** [bing-spellcheck](https://pypi.org/project/microsoft-bing-spellcheck/) for the [Bing Spell Check API](https://docs.microsoft.com/en-us/bing/search-apis/bing-spell-check/overview)
|
||||
|
||||
|
||||
### Search
|
||||
|
||||
* Using the **Bing Autosuggest SDK** [bing-search-autosuggest](https://pypi.org/project/microsoft-bing-autosuggest/) for the [Autosuggest API](https://docs.microsoft.com/en-us/bing/search-apis/bing-autosuggest/overview)
|
||||
* Using the **Bing Custom Search SDK** [bing-search-customsearch](https://pypi.org/project/microsoft-bing-customwebsearch/) for the [Custom Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview)
|
||||
* Using the **Bing Custom Image Search SDK** [bing-search-customimagesearch](https://pypi.org/project/microsoft-bing-customimagesearch/) for the [Custom Image Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/overview)
|
||||
* Using the **Bing Entity Search SDK** [bing-search-entitysearch](https://pypi.org/project/microsoft-bing-entitysearch/) for the [Entity Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-entity-search/overview)
|
||||
* Using the **Bing Image Search SDK** [bing-search-imagesearch](https://pypi.org/project/microsoft-bing-imagesearch/) for the [Image Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-image-search/overview)
|
||||
* Using the **Bing News Search SDK** [bing-search-newssearch](https://pypi.org/project/microsoft-bing-newssearch/) for the [News Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-news-search/overview)
|
||||
* Using the **Bing Video Search SDK** [bing-search-videosearch](https://pypi.org/project/microsoft-bing-videosearch/) for the [Video Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-video-search/overview)
|
||||
* Using the **Bing Visual Search SDK** [bing-search-visualsearch](https://pypi.org/project/microsoft-bing-visualsearch/) for the [Visual Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-visual-search/overview)
|
||||
* Using the **Bing Web Search SDK** [bing-search-websearch](https://pypi.org/project/microsoft-bing-websearch/) for the [Web Search API](https://docs.microsoft.com/en-us/bing/search-apis/bing-web-search/overview)
|
||||
|
||||
|
||||
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 Bing API key with which to authenticate the SDK's calls. [Create a new bing account, and try Bing Apis for free.](https://aka.ms/bingapisignup)
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. If you don't already have it, [install Python](https://www.python.org/downloads/).
|
||||
|
||||
This sample (and the SDK) is compatible with Python 2.7, 3.3, 3.4, 3.5 and 3.6.
|
||||
|
||||
2. General recommendation for Python development is to use a Virtual Environment.
|
||||
For more information, see https://docs.python.org/3/tutorial/venv.html
|
||||
|
||||
Install and initialize the virtual environment with the "venv" module on Python 3 (you must install [virtualenv](https://pypi.python.org/pypi/virtualenv) for Python 2.7):
|
||||
|
||||
```
|
||||
python -m venv mytestenv # Might be "python3" or "py -3.6" depending on your Python installation
|
||||
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/microsoft/bing-search-sdk-for-python.git
|
||||
```
|
||||
|
||||
2. Install the dependencies using pip.
|
||||
|
||||
```
|
||||
cd bing-search-sdk-for-python
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. Set up the environment variable `SPELLCHECK_SUBSCRIPTION_KEY` with your key if you want to execute SpellCheck tests.
|
||||
3. Set up the environment variable `AUTOSUGGEST_SUBSCRIPTION_KEY` with your key if you want to execute Autosuggest tests.
|
||||
3. Set up the environment variable `CUSTOMSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute CustomSearch tests.
|
||||
3. Set up the environment variable `CUSTOMIMAGESEARCH_SUBSCRIPTION_KEY` with your key if you want to execute CustomImageSearch tests.
|
||||
3. Set up the environment variable `ENTITYSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute EntitySearch tests.
|
||||
4. Set up the environment variable `IMAGESEARCH_SUBSCRIPTION_KEY` with your key if you want to execute ImageSearch tests.
|
||||
4. Set up the environment variable `NEWSSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute NewsSearch tests.
|
||||
4. Set up the environment variable `VIDEOSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute VideoSearch tests.
|
||||
4. Set up the environment variable `VISUALSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute VideoSearch tests.
|
||||
4. Set up the environment variable `WEBSEARCH_SUBSCRIPTION_KEY` with your key if you want to execute WebSearch tests.
|
||||
|
||||
|
||||
|
||||
## Demo
|
||||
|
||||
A demo app is included to show how to use the project.
|
||||
|
||||
To run the complete demo, execute `python example.py`
|
||||
|
||||
To run each individual demo, point directly to the file. For example (i.e. not complete list):
|
||||
|
||||
1. `python samples/sdk/spellcheck_samples.py`
|
||||
2. `python samples/sdk/entity_search_samples.py`
|
||||
3. `python samples/sdk/video_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
|
||||
|
||||
- https://github.com/microsoft/bing-search-sdk-for-python
|
|
@ -1,19 +1,13 @@
|
|||
|
||||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.Autosuggest.autosuggest_client._auto_suggest_client import AutoSuggestClient
|
||||
from models._models import Suggestions, SuggestionsSuggestionGroup, SearchAction,ErrorResponse
|
||||
import os
|
||||
from autosuggest_client import AutoSuggestClient
|
||||
from autosuggest_client.models import Suggestions, SuggestionsSuggestionGroup, SearchAction,ErrorResponse
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
|
||||
def autosuggest_lookup(subscription_key):
|
||||
"""AutoSuggestLookup.
|
||||
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.CustomImageSearch.custom_image_search_client._custom_image_search_client import CustomImageSearchClient
|
||||
import os
|
||||
from custom_image_search_client import CustomImageSearchClient
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
|
||||
# Add your Bing Custom Search subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
|
||||
#Add your Bing Custom Search subscription key to your environment variables.
|
||||
SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
|
||||
|
||||
def custom_image_search_result_lookup(subscription_key):
|
||||
"""CustomImageSearchResultLookup.
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
|
||||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.CustomWebSearch.custom_search_client._custom_search_client import CustomSearchClient
|
||||
import os
|
||||
from custom_search_client import CustomSearchClient
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
|
||||
|
||||
def custom_search_web_page_result_lookup(subscription_key):
|
||||
"""CustomSearch.
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.EntitySearch.entity_search_client._entity_search_client import EntitySearchClient
|
||||
from sdk.EntitySearch.entity_search_client.models._models import Place
|
||||
import os
|
||||
from entity_search_client import EntitySearchClient
|
||||
from entity_search_client.models import Place
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
|
||||
# Add your Bing Entity Search subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_ENTITY_SEARCH_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT']
|
||||
SUBSCRIPTION_KEY = os.environ['BING_ENTITY_SEARCH_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT']
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
def dominant_entity_lookup(subscription_key):
|
||||
"""DominantEntityLookup.
|
||||
|
@ -201,8 +193,8 @@ def error(subscription_key):
|
|||
except Exception as err:
|
||||
# The status code of the error should be a good indication of what occurred. However, if you'd like more details, you can dig into the response.
|
||||
# Please note that depending on the type of error, the response schema might be different, so you aren't guaranteed a specific error response schema.
|
||||
|
||||
print( "Exception occurred, with reason {}.\n".format(err))
|
||||
print( "\n This sample is triggered with an error")
|
||||
print( "\nException occurred, with reason {}.\n".format(err))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.ImageSearch.image_search_client._image_search_client import ImageSearchClient
|
||||
import os
|
||||
from image_search_client import ImageSearchClient
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
|
||||
|
||||
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT']
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT']
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
search_term = "canadian rockies"
|
||||
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.ImageSearch.image_search_client._image_search_client import ImageSearchClient
|
||||
from sdk.ImageSearch.image_search_client.models._image_search_client_enums import ImageType, ImageAspect, ImageInsightModule
|
||||
import os
|
||||
from image_search_client import ImageSearchClient
|
||||
from image_search_client.models import ImageType, ImageAspect, ImageInsightModule
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
|
||||
#SUBSCRIPTION_KEY = os.environ["BING_IMAGE_SEARCH_SUBSCRIPTION_KEY"]
|
||||
#ENDPOINT = os.environ['BING_IMAGE_SEARCH_ENDPOINT']
|
||||
# Add your Bing Entity Search subscription key to your environment variables.
|
||||
SUBSCRIPTION_KEY = os.environ["BING_IMAGE_SEARCH_SUBSCRIPTION_KEY"]
|
||||
ENDPOINT = os.environ['BING_IMAGE_SEARCH_ENDPOINT']
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
def image_search(subscription_key):
|
||||
"""ImageSearch.
|
||||
|
@ -186,7 +180,7 @@ def image_detail(subscription_key):
|
|||
print("Couldn't find image caption!")
|
||||
|
||||
# Pages including the image
|
||||
if image_detail.pages_including.value:
|
||||
if image_detail.pages_including:
|
||||
first_page = image_detail.pages_including.value[0]
|
||||
print("Pages including cound: {}".format(
|
||||
len(image_detail.pages_including.value)))
|
||||
|
@ -198,7 +192,7 @@ def image_detail(subscription_key):
|
|||
print("Couldn't find any pages including this image!")
|
||||
|
||||
# Related searched
|
||||
if image_detail.related_searches.value:
|
||||
if image_detail.related_searches:
|
||||
first_related_search = image_detail.related_searches.value[0]
|
||||
print("Related searches count: {}".format(
|
||||
len(image_detail.related_searches.value)))
|
||||
|
@ -210,7 +204,7 @@ def image_detail(subscription_key):
|
|||
print("Couldn't find any related searches!")
|
||||
|
||||
# Visually similar images
|
||||
if image_detail.visually_similar_images.value:
|
||||
if image_detail.visually_similar_images:
|
||||
first_visually_similar_images = image_detail.visually_similar_images.value[0]
|
||||
print("Visually similar images count: {}".format(
|
||||
len(image_detail.visually_similar_images.value)))
|
||||
|
@ -224,7 +218,7 @@ def image_detail(subscription_key):
|
|||
print("Couldn't find any visually similar images!")
|
||||
|
||||
# Image tags:
|
||||
if image_detail.image_tags.value:
|
||||
if image_detail.image_tags:
|
||||
first_image_tag = image_detail.image_tags.value[0]
|
||||
print("Image tags count: {}".format(
|
||||
len(image_detail.image_tags.value)))
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.NewsSearch.news_search_client._news_search_client import NewsSearchClient
|
||||
import os
|
||||
from news_search_client import NewsSearchClient
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
# Note: your endpoint should not include the /bing/v7.0 suffix
|
||||
#ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
|
||||
def news_search(subscription_key):
|
||||
"""NewsSearch.
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
|
||||
from sdk.SpellCheck.spell_check_client._spell_check_client import SpellCheckClient
|
||||
import os
|
||||
from spell_check_client import SpellCheckClient
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Spell Check subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SPELL_CHECK_SUBSCRIPTION_KEY']
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
# Add your Bing Spell Check subscription key to your environment variables.
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SPELL_CHECK_SUBSCRIPTION_KEY']
|
||||
|
||||
|
||||
|
||||
def spellcheck(subscription_key):
|
||||
"""SpellCheck.
|
||||
|
|
|
@ -1,23 +1,12 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.VideoSearch.video_search_client._video_search_client import VideoSearchClient
|
||||
from sdk.VideoSearch.video_search_client.models._video_search_client_enums import VideoPricing, VideoLength, VideoResolution, VideoInsightModule
|
||||
import os
|
||||
from video_search_client import VideoSearchClient
|
||||
from video_search_client.models import VideoPricing, VideoLength, VideoResolution, VideoInsightModule
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
|
||||
SUBSCRIPTION_KEY = None
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
|
||||
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
|
||||
def video_search(subscription_key):
|
||||
"""VideoSearch.
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
import json
|
||||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.VisualSearch.visual_search_client._visual_search_client import VisualSearchClient
|
||||
from sdk.VisualSearch.visual_search_client.models._models import (
|
||||
import os
|
||||
from visual_search_client import VisualSearchClient
|
||||
from visual_search_client.models import (
|
||||
VisualSearchRequest,
|
||||
CropArea,
|
||||
ImageInfo,
|
||||
|
@ -14,14 +9,11 @@ from sdk.VisualSearch.visual_search_client.models._models import (
|
|||
KnowledgeRequest,
|
||||
)
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
# Add your Bing Autosuggest subscription key to your environment variables.
|
||||
|
||||
ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/"
|
||||
SUBSCRIPTION_KEY = None
|
||||
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
|
||||
CWD = os.path.dirname(__file__)
|
||||
TEST_IMAGES = os.path.join(CWD, "TestImages")
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
import os,sys,inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
parent_dir2 = os.path.dirname(parent_dir)
|
||||
sys.path.insert(0, parent_dir2)
|
||||
from sdk.WebSearch.web_search_client import WebSearchClient
|
||||
from sdk.WebSearch.web_search_client.models._web_search_client_enums import SafeSearch
|
||||
import os
|
||||
from web_search_client import WebSearchClient
|
||||
from web_search_client.models import SafeSearch
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
sys.path.insert(0, current_dir)
|
||||
|
||||
# Add your Bing Search V7 subscription key to your environment variables.
|
||||
#SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
#ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
SUBSCRIPTION_KEY = None
|
||||
SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY']
|
||||
ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT']
|
||||
|
||||
|
||||
# Comment this logging mute out, if you want to include logging
|
||||
#logger = logging.getLogger() # get the default logger
|
||||
#logger.setLevel(50) # set the skip all log which is smaller than critical (50)
|
||||
|
||||
|
||||
def result_types_lookup(subscription_key):
|
||||
|
|
1
tools.py
1
tools.py
|
@ -1,6 +1,5 @@
|
|||
"""This file is just a sample launcher code.
|
||||
|
||||
Nothing is is related to Cognitive Services.
|
||||
"""
|
||||
try:
|
||||
from inspect import getfullargspec as get_arg_spec
|
||||
|
|
Загрузка…
Ссылка в новой задаче