diff --git a/CHANGELOG.md b/CHANGELOG.md index c686350..10125a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.0] + +### Added + +- `pages` (1 to 10) and `first` (the result to start at) on + `client.monitor.bing()`. + ## [0.5.0] ### Added diff --git a/README.md b/README.md index 08c303e..3ea5e0d 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,8 @@ charge. `client.countries(model="bing_aimode")` gives the supported countries. ### Bing Search `bing()` gets the Bing results with the AI Overview. The result has -`organicResults` and, when you request it and Bing shows one, `aioverview`. -Both have the same shape as in Google Search. Set `include` to get `html` (the +`organicResults`, `ads` when the page has ads and, when you request it and Bing +shows one, `aioverview`. They have the same shapes as in Google Search. Set `include` to get `html` (the results page), or `aioverview`. Set `aioverview` to `True`, or to `{"markdown": True}` to also get the AI Overview as markdown. `pages` (1 to 10, 2 credits for each page after the first) and `first` (the result to start at, default 1) select the diff --git a/src/cloro/_version.py b/src/cloro/_version.py index 3d18726..906d362 100644 --- a/src/cloro/_version.py +++ b/src/cloro/_version.py @@ -1 +1 @@ -__version__ = "0.5.0" +__version__ = "0.6.0" diff --git a/src/cloro/resources/monitor.py b/src/cloro/resources/monitor.py index 756401c..0791241 100644 --- a/src/cloro/resources/monitor.py +++ b/src/cloro/resources/monitor.py @@ -112,15 +112,31 @@ def google_news( # -- Bing Search (query-based) -------------------------------------- def bing( - self, query: str, country: str, *, include: Optional[Dict[str, Any]] = None, **extra: Any + self, + query: str, + country: str, + *, + pages: Optional[int] = None, + first: Optional[int] = None, + include: Optional[Dict[str, Any]] = None, + **extra: Any, ) -> Any: """Monitor Bing Search (SERP). ``POST /v1/monitor/bing``. The query can have a maximum of 3,500 characters after URL encoding. - The country selects the Bing market. ``include`` accepts ``html`` and + The country selects the Bing market. ``pages`` is 1 to 10. ``first`` is + the result to start at, and 1 is the first result. Bing shows no AI + Overview when ``first`` is more than 1. ``include`` accepts ``html`` and ``aioverview``. ``aioverview`` is ``True`` or ``{"markdown": True}``. """ return self._run( "/v1/monitor/bing", - {"query": query, "country": country, "include": include, **extra}, + { + "query": query, + "country": country, + "pages": pages, + "first": first, + "include": include, + **extra, + }, ) diff --git a/tests/test_client.py b/tests/test_client.py index 17607ce..e16517a 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -67,6 +67,22 @@ def handler(request: httpx.Request) -> httpx.Response: assert seen["url"].endswith("/v1/monitor/google") +def test_monitor_bing_sends_pages_and_first_only_when_set(): + bodies = [] + + def handler(request: httpx.Request) -> httpx.Response: + bodies.append(json.loads(request.content)) + return httpx.Response(200, json={"success": True, "result": {}}) + + client = make_client(handler) + client.monitor.bing(query="best crm", country="US") + client.monitor.bing(query="best crm", country="US", pages=3, first=41) + assert bodies == [ + {"query": "best crm", "country": "US"}, + {"query": "best crm", "country": "US", "pages": 3, "first": 41}, + ] + + def test_monitor_bing_aimode_request_and_response(): seen = {}