Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cloro/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.0"
__version__ = "0.6.0"
22 changes: 19 additions & 3 deletions src/cloro/resources/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)
16 changes: 16 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
Loading