From 8d7e3873aba35dee38771e4cb4f36c4f805c48f4 Mon Sep 17 00:00:00 2001 From: moon Date: Thu, 5 Sep 2024 13:21:37 -0700 Subject: [PATCH] revert cookie issue --- package.json | 2 +- src/scraper.ts | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index f22f79f..4481682 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scraper", "crawler" ], - "version": "0.0.10", + "version": "0.0.11", "main": "dist/default/cjs/index.js", "types": "./dist/types/index.d.ts", "exports": { diff --git a/src/scraper.ts b/src/scraper.ts index 48a76d0..93fa868 100644 --- a/src/scraper.ts +++ b/src/scraper.ts @@ -567,16 +567,8 @@ export class Scraper { */ public async setCookies(cookies: (string | Cookie)[]): Promise { const userAuth = new TwitterUserAuth(this.token, this.getAuthOptions()); - const cookiesData = cookies.map((cookieData) => - Cookie.fromJSON(JSON.stringify(cookieData)), - ); - - for (const cookie of cookiesData) { - if (cookie !== null) { - await userAuth.cookieJar().setCookie(cookie, twUrl); - } else { - console.error('Invalid cookie:', cookie); - } + for (const cookie of cookies) { + await userAuth.cookieJar().setCookie(cookie, twUrl); } this.auth = userAuth;