the-convocation / twitter-scraper

A port of n0madic/twitter-scraper to Node.js.
https://the-convocation.github.io/twitter-scraper/
MIT License
211 stars 43 forks source link

Scraper.login doesn't work #91

Closed kws1207 closed 4 months ago

kws1207 commented 5 months ago

Tried below code:

import { Scraper } from "@the-convocation/twitter-scraper";
import { configDotenv } from "dotenv";

configDotenv();
const scraper = new Scraper();

(async () => {
  await scraper.login(
    process.env.TWITTER_USERNAME || "",
    process.env.TWITTER_PASSWORD || ""
  );
})();

Got below error:

/Users/kws/projects/twitter-scraper-test/node_modules/@the-convocation/twitter-scraper/dist/auth-user.js:85
                throw new Error(`Unknown subtask ${next.subtask.subtask_id}`);
                      ^

Error: Unknown subtask LoginEnterAlternateIdentifierSubtask
    at TwitterUserAuth.login (/Users/kws/projects/twitter-scraper-test/node_modules/@the-convocation/twitter-scraper/dist/auth-user.js:85:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Scraper.login (/Users/kws/projects/twitter-scraper-test/node_modules/@the-convocation/twitter-scraper/dist/scraper.js:282:9)
    at async file:///Users/kws/projects/twitter-scraper-test/index.js:8:3

Minimum reproducible example: https://github.com/kws1207/twitter-scraper-test

Maybe it could be related to this commit.

wik3d commented 5 months ago

Hey @kws1207, This error is a result of Twitter detecting suspicious login activity with your account, and they require you to input your email as an additional piece of info to prove it's you.

I've pushed a fix to my fork of this repo, and I hope I have also opened a pull request and hope it will be validated soon.

My fork: https://github.com/wik3d/twitter-scraper/tree/handled-new-error The fix I pushed: https://github.com/the-convocation/twitter-scraper/compare/main...wik3d:twitter-scraper:handled-new-error

kws1207 commented 4 months ago

It seems resolved in 0.13.1.