0.6.2 • Published 3 years ago

web-search v0.6.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

web-search

A package to provide search links for website from a search term.

Web Search on NPM

Install

# Using yarn
yarn add web-search

# Using npm
npm install web-search

Usage

Basically, you just need to provide the website to make the search and the search term.

import webSearch from "web-search";

webSearch("npmjs.com", "web-search");
// => "https://www.npmjs.com/search?q=web-search"

API

webSearch

The main function, get search URL in a website from a search term.

  • 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
Parameters
ParameterTypeDescriptionExample
websiteURLstringThe website to make the search."npmjs.com"
searchQuerystringThe search term."web-search"

webSearchData

If you just want to make cool stuff with the data behind the webSearch, webSearchData returns it with the name and URLs of each website.

import webSearch, { webSearchData } from "web-search";

webSearchData();
// => {
//     websites: [
//         {
//             "name": "Example Domain",
//             "url_prefix": "https://example.com/search?q="
//         },
//         ...
//     ]
// }
Interfaces
  • WebSearchData

The data from data.json, storing the websites.

websites is an array with these properties:

PropertyTypeDescriptionExample
namestringWebsite name."DuckDuckGo"
url_prefixstringThe search url before the search term."https://duckduckgo.com/?q="
url_suffixstringThe (optional) url after the search term."&iax=images&ia=images"

It is recommended to include additional query variables in url_suffix.

Contributing

At the end of the day, web-search is greater with more and more websites. So don't hesitate to contribute!

Check here the instructions.

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago