Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
serper
Advanced tools
Readme
Scrape Google search results using Serper, the fastest and most affordable SERP API.
# npm
npm install serper
# yarn
yarn add serper
# pnpm
pnpm add serper
import { Serper } from "serper"; // ES Modules
const { Serper } = require("serper"); // CommonJS Modules
const serper = new Serper({
apiKey: process.env.SERPER_API_KEY // Get your API key at https://serper.dev/api-key
});
const results = await serper.search("search terms");
Configuration is very simple; just three things.
const serper = new Serper({
apiKey: process.env.SERPER_API_KEY, // Your API key, this is required
timeout: 10000, // Request timeout in milliseconds, 10000 by default
doCache: true // Enable to cache responses, true by default
});
The client usage is just as simple as what was shown in the quick start. Simply initializing a client, then making requests with async methods.
Currently, you can search under all supported Serper API routes. They are:
All of these can be called using the exact same client API and the respective name of the route as the function name. By replacing "search" in the quick start function, you can run any search imaginable!
Pagination is built in to Serper with three simple functions, nextPage
, prevPage
and toPage
. Currently, due to API limitations, there is no indicator in nextPage
as to the end of all pages. The prevPage
function just returns the first page if you try to go negative. The self explanatory toPage
results in the specified page.
All client responses contain nextPage
and prevPage
, as well as all pagination responses.
let results = await serper.search("dog shelters");
for (let x = 0; x < 5; x++) {
results = await results.nextPage();
}
All responses from the Serper Client are locally cached to reduce credit usage during pagination and repeated searching. The cache can easily be disabled by setting the cache
config value to false
, although this is not recommended as it will significantly slow down your application, and should only be used when current information (ie. news) is needed.
API docs are available online here, and a large collection of usage examples are available in the examples directory.
Note: All examples assume top level await, which is supported in modern Node.js and most modern browers.
This code is released under the permissible MIT license. Anyone can contribute, use, redistribute, and sell this library without any credit, although it is appreciated.
FAQs
A client for the Serper Google Search API.
The npm package serper receives a total of 15 weekly downloads. As such, serper popularity was classified as not popular.
We found that serper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.