Releases: typicalninja/google-sr
[email protected]
This major release updates the CLI to align with the latest google-sr API changes, introduces expanded conversion capabilities, and includes important architectural improvements for better performance and compatibility.
Breaking Changes
Updated CLI to use renamed parser API by @typicalninja (#85)
The CLI has been updated to use the new parsers option and ResultParser type from google-sr instead of the deprecated resultTypes and ResultSelector names. This change ensures consistency with the core library's updated terminology.
Migration Required:
- The CLI option
--resultTypes/-ris now--parsers/-rto match the new API
Rename CurrencyResult to UnitConversionResult by @typicalninja (#79)
The parser has been renamed to reflect its expanded capabilities. The CurrencyResult was found to work effectively for all types of conversion queries: currency, units, measurements, temperature, and more, not just currency conversions. This rename provides a more accurate representation of its full functionality.
What's new
Google News parser by @tresorama and @typicalninja (#71)
Add support for parsing results from the Google News tab.
Questions? Feedback? Open an issue or start a discussion.
View the full changelog • See all commits for this release
Like the project? Star it on GitHub ★
[email protected]
This release introduces significant improvements to existing parsers, adds new parsing capabilities, and includes a range of internal and API-level changes that enhance the library's performance and usability.
Special thanks to our new contributor @tresorama for their valuable contributions to this release!
Breaking changes
Replace Axios with native fetch by @typicalninja (#76)
We've removed the Axios dependency in favor of the native Fetch API. This change reduces bundle size and improves compatibility across environments, including modern runtimes like Deno and Bun.
The requestConfig option now uses the RequestOptions interface (extending RequestInit) instead of AxiosRequestConfig.
requestConfig: {
- params: { safe: "active" }
+ queryParams: { safe: "active" }
}Rename CurrencyResult to UnitConversionResult by @typicalninja (#79)
The original CurrencyResult selector was found to work effectively for all types of conversion queries: currency, distance, weight, temperature, and more, not just currency conversions. This rename better captures its full functionality and provides a more accurate representation of its capabilities.
CurrencyResult→UnitConversionResultCurrencyResultNode→UnitConversionResultNodeResultTypes.CurrencyResult→ResultTypes.UnitConversionResult
Rename strictSelector to noPartialResults by @typicalninja (#80)
The strictSelector option has been renamed to noPartialResults for improved clarity and to better describe its functionality. The behavior remains unchanged.
Parser and result type API renamed for clarity by @typicalninja (#85)
We've clarified the core API terminology to eliminate confusion and improve developer experience:
ResultSelector→ResultParserresultTypes→parsers
This change better reflects the purpose of each component, improving readability and maintainability.
Improved type safety and parser consistency by @typicalninja (#92)
This release brings essential type improvements across all parsers. Key enhancements include:
- Proper generic inference with
noPartialResults - Required fields in result types now accurately reflect actual data.
- All empty strings are normalized to
undefined(breaking change if you previously relied on empty string values)
OrganicResultNode.description is now optional by @typicalninja (#93)
In real-world search results, not all organic entries contain a description. To reflect this, the OrganicResultNode.description field is now explicitly optional and may be undefined.
Removed ResultNodeTyper helper by @typicalninja (#73)
The old ResultNodeTyper utility has been removed to simplify the typing model. You can now define custom result node types with a plain interface. This is primarily an internal change, but if you have custom selectors using this type, you'll need to update them.
- import { ResultNodeTyper } from 'google-sr';
- type MyCustomNode = ResultNodeTyper<"CUSTOM", 'link' | 'title'>;
+ interface MyCustomNode {
+ type: "CUSTOM";
+ link: string;
+ title: string;
+ }What's new
Google News parser by @tresorama (#71)
Add support for parsing results from the Google News tab (tbm=nws).
import { NewsResult, search } from 'google-sr';
const results = await search({
query: 'latest news on AI',
parsers: [NewsResult],
requestConfig: {
queryParams: {
tbm: 'nws', // Set tbm to nws for news results
}
}
});Related Searches parser by @typicalninja (#96)
Adds support for parsing result from the "Related searches" section.
google-sr is now available on jsr.io
You can find it here: https://jsr.io/@typical/google-sr
Improvements
Add thumbnail URL parsing to NewsResult by @typicalninja (#89)
The NewsResult parser now extracts the thumbnail URL when available.
OrganicResult now includes source and isAd properties by @typicalninja (#90)
The OrganicResultNode now contains:
source: A human-readable domain name for the resultisAd: Boolean to detect whether a result is sponsored
Note: The isAd property implementation is based on reference data obtained through browser testing, as Google did not return sponsored ads during our automated testing with google-sr. If you encounter any issues with ad detection, please create an issue for help.
Other small fixes
Fixed delay option in searchWithPages by @typicalninja (#98)
The delay option in searchWithPages now functions correctly, applying the specified delay between paginated requests to prevent rate limiting issues.
Early exit optimization when noPartialResults is true by @typicalninja (#83)
When noPartialResults is enabled, parsers now exit immediately upon encountering unusable or empty data. This optimization prevents unnecessary processing when complete result properties are required.
Dependency maintenance
All dependencies and development dependencies have been updated to their latest stable versions.
CJS / ESM Notice
Starting in version 7.x (subject to change), we plan to publish ESM-only releases and remove the CJS build. As a result, you will no longer be able to use require() to import this package; you must use import instead.
If you're using Node.js v20 or later, you can still use
require()with ESM modules natively. See release note
Check the readme for more information
Questions? Feedback? Open an issue or start a discussion.
View the full changelog • See all commits for this release
Like the project? Star it on GitHub ★
[email protected]
This release introduces significant improvements to selector functionality, adds new selectors for Google News and related searches, and includes important changes for better maintainability and future compatibility.
Special thanks to our new contributor @tresorama for their valuable contributions to this release!
Breaking changes
Rename CurrencyConvertSelector to UnitConversionSelector by @typicalninja (#79)
The original CurrencyResult selector was found to work effectively for all types of conversion queries: currency, distance, weight, temperature, and more, not just currency conversions. This rename better captures its full functionality and provides a more accurate representation of its capabilities.
- import { CurrencyConvertSelector } from 'google-sr-selectors';
+ import { UnitConversionSelector } from 'google-sr-selectors';What's new
Google News selector support by @tresorama (#71)
Add support for parsing results from the Google News tab (tbm=nws).
Related Searches selector support by @typicalninja
Added new RelatedSearchesSelector for extracting related search suggestions that appear at the bottom of Google search results.
CJS / ESM Notice
Starting in version 7.x (subject to change), we plan to publish ESM-only releases and remove the CJS build. As a result, you will no longer be able to use require() to import this package; you must use import instead.
If you're using Node.js v20 or later, you can still use
require()with ESM modules natively. See release note
Check the readme for more information
Questions? Feedback? Open an issue or start a discussion.
View the full changelog • See all commits for this release
Like the project? Star it on GitHub ★
5.0.0
What's Changed
In a recent Google update, the ability to access search result pages without enabling JavaScript was disabled. (See #51 for more details.)
Using resources such as this Hacker News thread, A fix have been implemented that bypasses the JavaScript requirement by utilizing an alternate page version served to specific user agents.
- refactor: bypass JavaScript requirement for Google search by @typicalninja in #53
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-sr/CHANGELOG.md
Full Changelog: 4.1.0...5.0.0
[email protected]
What's Changed
Patch Changes
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-that/CHANGELOG.md
Full Changelog: https://github.com/typicalninja/google-sr/compare/[email protected]@1.1.1
[email protected]
What's Changed
Major Changes
-
refactor: bypass JavaScript requirement for Google search by @typicalninja in #53 (#51)
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-sr-selectors/CHANGELOG.md
Full Changelog: https://github.com/typicalninja/google-sr/compare/[email protected]@2.0.0
4.1.0
What's Changed
Minor Changes
- 0d21c7a: Implement knowledge graph results (by @typicalninja in #46)
Patch Changes
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-sr/CHANGELOG.md
Other changes
- docs: mention deno install/support in readme by @typicalninja in #42
- chore: Update repo tools by @typicalninja in #43
- chore: Add pkg-pr-new by @typicalninja in #44
- chore: update project (local) typescript by @typicalninja in #45
- feat: Add knowledge graph results by @typicalninja in #46
- chore: setup typedocs with gh pages by @typicalninja in #49
Full Changelog: https://github.com/typicalninja/google-sr/compare/[email protected]
[email protected]
What's Changed
Minor Changes
- 0d21c7a: Add support for knowledge graph results (by @typicalninja in #46)
Patch Changes
- Updated dependencies [0d21c7a]
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-that/CHANGELOG.md
Full Changelog: https://github.com/typicalninja/google-sr/compare/[email protected]@1.1.0
[email protected]
What's Changed
Minor Changes
- 0d21c7a: Add selectors for knowledge graph results (by @typicalninja in #46)
Patch Changes
- fabb572: patch the translate search result selectors (by @typicalninja in #48)
Package Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-sr-selectors/CHANGELOG.md
Full Changelog: https://github.com/typicalninja/google-sr/compare/[email protected]@1.1.0
[email protected]
What's Changed
Major Changes
-
563bfc4: Update dictionary selectors with accurate definitions (@typicalninja in #28)
This uses the updated dictionary definitions from google-sr-selectors as a response to google updating their result structure.
Previously, dictionary definitions were returned as a [string, string]. Now, they are returned as an object with the following properties:
interface DictionaryDefinition { partOfSpeech: string; definition: string; example: string; synonyms: string[]; }
Please take steps to update your code to use the new dictionary definition structure.
-
c332095: Rewrite the api to be customizable (@typicalninja in #15/#32)
google-sr has been completely rewritten to be more customizable. It is possible to create your own selector functions and use them to scrape the data you want.
filterResultsoption was replaced byresultTypeswhich accepts a function instead of a string. This allows you to add your own custom selectors to be used as a parser.search({ - filterResults: [ResultTypes.SearchResult] + resultTypes: [] })Check the newly added api documentation here
Minor Changes
-
5676a7a: Support custom selectors (@typicalninja in #33)
Use the new
ResultNodeTyperto create a custom node, and use theResultSelectorto create a function that will parse the raw html for results and return a node.import { ResultNodeTyper, ResultSelector } from "google-sr"; // first argument is the "type" value (string) of the node, second is all the properties of the node type DidYouKnow = ResultNodeTyper< "SOMETYPE", "prop1" | "prop2" > & // properties that are not string can be defined as this { descriptions: string[] }; const selector: ResultSelector<DidYouKnow> = ($, strictSelector) => { // return node }; search({ resultTypes: [selector] });
-
d98c496: Remove uneeded top level options (@typicalninja in #37)
Removed the
safemodetop-level options as the same result can be achieved using the requestConfig option.const queryResult = await search({ - safemode: true, // requestConfig is of type AxiosRequestConfig + requestConfig: { + params: { + // enable "safe mode" + safe: 'active' + }, + }, });
Full Changelog: https://github.com/typicalninja/google-sr/blob/master/packages/google-sr/CHANGELOG.md