Repository navigation
feat(baidu): search returns Baidu's own cards in SearchResponse.cards (0.86.0, SCR-760) - #114
Merged
Merged
Conversation
… (0.86.0, SCR-760) Baidu mixes its own cards (Baike, its AI answer, images, goods, notes, a map, latest news ...) with the organic results, and for a popular term they can fill the whole first page, which came back as an empty `results`. The API now lists them in `cards` (scrape-badger/scrapebadger#3658). - `Card`: position, type, title, url, baidu_url, snippet, every field optional. `position` is Baidu's number for the place on the page, shared with the organic results; `OrganicResult.position` is unchanged (rank among organic results). - `SearchResponse.cards` defaults to an empty list, so answers without the key parse as before. - Exported from `scrapebadger.baidu` and as `scrapebadger.BaiduCard`. - No method signature changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
baidu.search()returns Baidu's own cards inSearchResponse.cards.Baidu mixes its own cards (Baike, its AI answer, images, goods, notes, a map, latest news ...) with the organic results. For a popular term they can take every place on page 1, which came back as an empty
results. The API now lists them next to the results.Card:position,type,title,url,baidu_url,snippet. Every field is optional.Card.positionis Baidu's number for the place on the page, shared with the organic results.OrganicResult.positionis unchanged (rank among organic results), so the two are not the same sequence.SearchResponse.cardsdefaults to an empty list, so an answer without the key parses as before.scrapebadger.baiduand asscrapebadger.BaiduCard.Version 0.86.0, changelog entry included.
Checks
ruff check,ruff format --check,mypy src/andpytest --ignore=tests/e2epass, astest.ymlruns them.New tests in
tests/test_baidu.py:test_a_page_of_only_cards_has_cards_and_no_results,test_an_answer_without_cards_parses_to_an_empty_list,test_card_is_exported;test_search_response_keeps_every_fieldnow covers a card.Release
Do not merge or publish before the API change is live. Then: merge, create the GitHub release
v0.86.0(publish.ymlpushes to PyPI).Note:
mainalready holds 0.85.0 (Twitter community search) and the latest tag isv0.84.0. If 0.85.0 is not tagged first, a 0.86.0 release carries it too; its changelog entry is in place.Related
cards(SCR-760) docs#218🤖 Generated with Claude Code