@millenmortier/google-scholar-query
v0.1.2
Published
A tiny library to make throttles requests to Google Scholar
Downloads
4
Readme
Google Scholar query
A tiny library to ease making requests to Google Scholar.
Installation
npm i @millenmortier/google-scholar-query
Usage
The main file exports two mechanisms:
Promise-based
import { queryAsPromise } from '@millenmortier/google-scholar-query';
(async () => {
const results = await queryAsPromise('YOUR_GOOGLE_SCHOLAR_QUERY_HERE');
})();
Event-based
import { queryAsEvent } from '@millenmortier/google-scholar-query';
const emitter = queryAsEvent('YOUR_GOOGLE_SCHOLAR_QUERY_HERE');
const allData = [];
emitter.on('data', (newResults) => {
// newResults will be a new page of articles
allData = allData.concat(newResults);
});
emitter.on('end', () => {
// all results have been fetched
});
emitter.on('error', (err) => {
// An error occurred
});
emitter.on('tooManyRequests', () => {
// Google is rate-limiting us, so it's best to try again after a while
});