Skip to content

Commit

Permalink
implement cookieJar support
Browse files Browse the repository at this point in the history
fixes issue facundoolano#676
  • Loading branch information
Peeter Marvet committed Apr 7, 2024
1 parent 2fa6157 commit c1cf82b
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/utils/request.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import requestLib from 'got';
import throttled from './throttle.js';
import {CookieJar} from 'tough-cookie';
import createDebug from 'debug';

const cookieJar = new CookieJar();
const debug = createDebug('google-play-scraper');

function doRequest (opts, limit) {
let req;

opts.cookieJar = cookieJar;

if (limit) {
req = throttled(
requestLib, {
Expand All @@ -24,7 +29,7 @@ function doRequest (opts, limit) {
});
}

async function request (opts, limit) {
async function request(opts, limit) {
debug('Making request: %j', opts);
try {
const response = await doRequest(opts, limit);
Expand Down
93 changes: 89 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"debug": "^3.1.0",
"got": "^11.8.6",
"memoizee": "^0.4.14",
"ramda": "^0.29.0"
"ramda": "^0.29.0",
"tough-cookie": "^4.1.3"
},
"devDependencies": {
"chai": "^4.3.7",
Expand Down

0 comments on commit c1cf82b

Please sign in to comment.