asyncbing API reference#
Searching#
- asyncbing.search(auth: str, *, session: Optional[aiohttp.client.ClientSession] = None)#
Takes a auth token, as well as an optional aiohttp session.
It is recommended to use this function instead of
asyncbing.Translateas it returns it, and you can useasync withsyntax in it.example:
async with asyncbing.search('AUTHTOKEN') as searching: await searching.fetch...
- class asyncbing.Search(auth: str, *, session: Optional[aiohttp.client.ClientSession] = None)#
The searching part of asyncbing.
If you manually initialize this class, you won’t be able to use the async with syntax. It’s recommended to use
asyncbing.search().- async fetch(search: str) asyncbing.searchresponse.SearchResponse#
This function is a coroutine.
Searches with the bing api for the search string provided, with the global market set.
- async search(search: str) asyncbing.searchresponse.SearchResponse#
This function is a coroutine.
An alias for
asyncbing.Search.fetch()
- class asyncbing.SearchResponse(data)#
Represents a Bing Response (not a search result response)
Warning
You must not manually initialize this!
- getMany(amount: int, *, start: int = 0) Tuple[asyncbing.searchresult.SearchResult]#
Returns as many
asyncbing.SearchResultas you want as the max defined by the int passed into the function. has an optionalstartkwarg. Defaults to 0.
- getNext() asyncbing.searchresult.SearchResult#
Gets the next result and returns a
asyncbing.SearchResult
- getOne() asyncbing.searchresult.SearchResult#
Gets the top search result and returns a
asyncbing.SearchResult.
- getThree() Tuple[asyncbing.searchresult.SearchResult, asyncbing.searchresult.SearchResult, asyncbing.searchresult.SearchResult]#
Gets the top three search results and returns a tuple of
asyncbing.SearchResult
A searchresult represents a search result response from bing (you get it from asyncbing.SearchResponse).
- class asyncbing.SearchResult(data)#
Represents a Bing Search Result (like url, snippet, name, etc)
Warning
You must not manually initialize this!
- property dateLastCrawled: datetime.datetime#
Returns when the page was last crawled by Bing as a
datetime.datetimeobject.
- property displayUrl: str#
The display url of the Search Response. I don’t actually know what this is, I think it is a trimmed version of the url
I have no idea what this is. Returns a bool if page is navigational.
Translating#
- asyncbing.translate(auth: str, *, region: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None) asyncbing.translate.Translate#
Takes a auth token, as well as an optional aiohttp session.
It is recommended to use this instead of manually initializing
asyncbing.Translatebecause you can use theasync withsyntax, and it returnsasyncbing.Translate.example:
async with asyncbing.translate('AUTHTOKEN', region='eastus') as translating: await translating.translate...
- class asyncbing.Translate(auth: str, *, region: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None)#
The translating part of asyncbing. If you use this class, you won’t be able to use the async with syntax. It’s recommended to use
asyncbing.translate()- async translate(query: str, *, tolang: str = 'en', fromlang: Optional[str] = None) asyncbing.translateresponse.TranslateResponse#
This function is a coroutine.
Translate the given query with an optional tolang language to translate to, as well as an optional fromlang language to translate from. If tolang isn’t provided, it will auto translate to english. If fromlang isn’t provided, it will auto translate from autodetect.
- class asyncbing.TranslateResponse(data: dict)#
The class for the Bing Translate Response.
Warning
You must not manually initialize this!
Exceptions#
- class asyncbing.BingException#
A generic exception for all bing-related exceptions. You can catch all exceptions with this.
- class asyncbing.BadAuth#
An invalid authorization was passed in
- class asyncbing.NotEnoughResults#
There weren’t enough results.