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.
filterResults
option was replaced byresultTypes
which 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
ResultNodeTyper
to create a custom node, and use theResultSelector
to 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
safemode
top-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