Package: py-bing-search
Intro=====Extremely thin python wrapper for Microsoft Azure Bing Search API. Please note that this module does not use the Bing Search API 2.0 AppIDs which will be deprecated on August 1, 2012. This module requires that you sign up to the Windows Azure Marketplace and apply for an application key.The modules uses OAuth, so you'll need to get your key here (free for up to 5K/Mon):* [All Purpose](https://datamarket.azure.com/dataset/5BA839F1-12CE-4CCE-BF57-A49D98D29A44)* [Web Search Only](https://datamarket.azure.com/dataset/8818F55E-2FE5-4CE3-A617-0B8BA8419F65)Installation=====#####for python 2.7.*```shpip install py-bing-search```#####for python 3.*```shpip3 install py-bing-search```*Requires the requests library.Usage=====Remember to set the `API_KEY` as your own.####For Web Results:```py>>> from py_bing_search import PyBingWebSearch>>> search_term = "Python Software Foundation">>> bing_web = PyBingWebSearch('Your-Api-Key-Here', search_term, web_only=False) # web_only is optional, but should be true to use your web only quota instead of your all purpose quota>>> first_fifty_result= bing_web.search(limit=50, format='json') #1-50>>> second_fifty_result= bing_web.search(limit=50, format='json') #51-100>>> print (second_fifty_result[0].description)u'Python Software Foundation Home Page. The mission of the Python Software Foundation is to promote, protect, and advance the Python programming language, and to ...'```What you get is a list of WebResult() instances, each comes with the following values:```self.title:         title of the resultself.url:           the url of the resultself.description:   description for the resultself.id:            bing id for the page#Meta info:self.meta.uri:      the search uri for bingself.meta.type:     for the most part WebResult```####For Image Results:```py>>> from py_bing_search import PyBingImageSearch>>> bing_image = PyBingImageSearch('Your-Api-Key-Here', "x-box console", image_filters='Size:medium+Color:Monochrome') #image_filters is optional>>> first_fifty_result= bing_image.search(limit=50, format='json') #1-50>>> second_fifty_result= bing_image.search(limit=50, format='json') #51-100>>> print (second_fifty_result[0].media_url)...```What you get is a list of ImageResult() instances, each comes with the following values:```self.id: id of the resultself.title: title of the resulting imageself.media_url: url to the full size imageself.source_url: url of the website that contains the source imageself.width: width of the imageself.height: height of the imageself.file_size: size of the image (in bytes) if availableself.content_type the MIME type of the image if availableself.meta: meta info#Meta info#:meta.uri: the search uri for bingmeta.type: for the most part ImageResult```####For Video Results:```py>>> from py_bing_search import PyBingVideoSearch>>> bing_video = PyBingVideoSearch('Your-Api-Key-Here', "cats")>>> first_fifty_result= bing_video.search(limit=50, format='json') #1-50>>> second_fifty_result= bing_video.search(limit=50, format='json') #51-100>>> print (second_fifty_result[0].media_url)...```What you get is a list of VideoResult() instances, each comes with the following values:```self.id: id of the resultself.title: title of the resulting Videoself.media_url: url to the full size Videoself.display_url: url to display on the search result.self.run_time: run time of the videoself.meta: meta info#Meta info#:meta.uri: the search uri for bingmeta.type: for the most part VideoResult```####For News Results:```py>>> from py_bing_search import PyBingNewsSearch>>> bing_news = PyBingNewsbSearch('Your-Api-Key-Here', "US Election")>>> first_fifty_result= bing_news.search(limit=50, format='json') #1-50>>> second_fifty_result= bing_news.search(limit=50, format='json') #51-100>>> print (second_fifty_result[0].url)...```What you get is a list of NewsResult() instances, each comes with the following values:```self.id: id of the resultself.title: title of the resulting Newsself.url: url to the Newsself.description: description of the articleself.date: date of the Newsself.meta: meta info#Meta info#:meta.uri: the search uri for bingmeta.type: for the most part NewsResult```## Searching for a specific number of results.You secan also run __*search_all*__ to keep searching until it fills your required quota. Note that this will make an unpredictable number of api calls (hence drains your credits).```py>>> from py_bing_search import PyBingWebSearch>>> bing_web = PyBingNewsbSearch('Your-Api-Key-Here', "Python Software Foundation")>>> result_list = bing_web.search_all(limit=130, format='json') #will return result 1 to 130>>> len(result_list) == 130True>>> result_list = bing_web.search_all(limit=130, format='json') #will return result 131 to 260```__*search_all()*__ is available in all PyBing*Search classes.## Custom parametersIf you need more control via *custom parameters* (and you know what you're doing), you can include a __*custom_param*__ parameter as follows:```py>>> from py_bing_search import PyBingWebSearchweb_bing = PyBingWebSearch('Your-Api-Key-Her', "some bad search", custom_params="&Adult='Strict'")result_list = bing_web.search_all(limit=100, format='json')# result_list should now contain 100 results that are filetered by safesearch.```Don't forget to include the __*&__* at the start of your custom_param or the search will return the error msg: "py_bing_search.py_bing_search.PyBingWebException: Request returned with code 400, error msg: The provided format is not supported."The optional parameter __*custom_param*__ is available in all PyBing*Search constructors.