web-search
Version:
A package to provide search URLs for websites from a search term.
41 lines (40 loc) • 1.24 kB
TypeScript
import { WebSearchData } from "./types";
/**
* Get search URL in a website from a search term.
* @param websiteURL The website to make the search
* @param searchQuery The search term
* @returns The complete URL to the search on website
*
* @example ```ts
* // Allow compact/human-friendly URL
* webSearch("google.com", "how to make a carrot cake");
* => "https://google.com/search?q=how%20to%20make%20a%20carrot%20cake"
*
* // Allow complete URL, just get the host name
* webSearch("https://duckduckgo.com/?justGet=theHostName", "dogecoin");
* => "https://duckduckgo.com/?q=dogecoin"
*
* // Returns undefined with a unknown website
* webSearch("ea6194cb-47e1-4165-9090-0fa80539e82a.com", "what is uuid?");
* => undefined
* ```
*/
export default function webSearch(websiteURL: string, searchQuery: string): string;
/**
* @returns The complete data of `web-search`,
* with the name and URLs of each website.
*
* @example ```ts
* webSearchData();
* // => {
* // websites: [
* // {
* // "name": "Example Domain",
* // "url_prefix": "https://example.com/search?q="
* // },
* // ...
* // ]
* // }
```
*/
export declare function webSearchData(): WebSearchData;