Hello all ,
I want to search tweets based on a given hashtag for my thesis project. Below is the source code, but I got error 404.
import { Scraper, SearchMode } from "@the-convocation/twitter-scraper";
import { cycleTLSExit, cycleTLSFetch } from "@the-convocation/twitter-scraper/cycletls";
import dotenv from "dotenv";
import path from "path";
dotenv.config({ path: path.join(process.cwd(), ".env.local") });
const username = process.env["TWITTER_USERNAME"]!;
const password = process.env["TWITTER_PASSWORD"]!;
const email = process.env["TWITTER_EMAIL"]!;
const HASHTAG = "#paris";
const MAX_TWEETS = 50;
const main = async () => {
const scraper = new Scraper({ fetch: cycleTLSFetch });
try {
console.log("Logging in...");
await scraper.login(username, password, email);
console.log("Login successful\n");
console.log(`Searching for tweets with: ${HASHTAG}`);
const tweets = [];
let scraped_result = scraper.searchTweets(HASHTAG, 1000, SearchMode.Latest);
for await (const tweet of scraped_result) {
tweets.push(tweet);
console.log(`[${tweets.length}] @${tweet.username}: ${tweet.text?.substring(0, 80)}...`);
}
console.log(`\nTotal tweets fetched: ${tweets.length}`);
} catch (error) {
console.error("Error:", error);
} finally {
cycleTLSExit();
}
};
main();
error stack is:
`> start
tsx src/hashtag.ts
[dotenv@17.2.3] injecting env (16) from .env.local -- tip: 🗂️ backup and recover secrets: https://dotenvx.com/ops
Logging in...
Login successful
Searching for tweets with: #paris
Error: ApiError: Response status: 404 | headers: "cache-control: no-cache, no-store, max-age=0\ncf-cache-status: DYNAMIC\ncf-ray: 9d5bdb137eaa62c5-HAM\ncontent-length: 0\ncontent-type: text/plain;charset=UTF-8\ndate: Sun, 01 Mar 2026 23:14:03 GMT\norigin-cf-ray: 9d5bdb137eaa62c5-ATL\nperf: 7402827104\nserver: cloudflare envoy\nset-cookie: ct0=91771dff9f2bbdb26ecb65048a685753d26bc90db15285faa6146bdf9877ee090b610d45719675619168711dc0bea39f8e36da195b2912a837f6073788ed5b1ffaa280fcdebf24830fe5396d75b1c699; Max-Age=34214400; Expires=Thu, 01 Apr 2027 23:14:03 GMT; Path=/; Domain=.x.com; Secure; SameSite=Lax\nstrict-transport-security: max-age=631138519; includeSubdomains\nx-rate-limit-limit: 50\nx-rate-limit-remaining: 49\nx-rate-limit-reset: 1772407743\nx-response-time: 9\nx-served-by: t4_a\nx-transaction-id: f9f16bd75027add8" | data:
at ApiError.fromResponse (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:58:12)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async requestApi (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:575:12)
at async getSearchTimeline (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:1857:15)
at async fetchSearchTweets (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:1809:20)
at async main (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\src\hashtag.ts:28:22) {
response: Response {
status: 404,
statusText: '',
headers: Headers {
'cache-control': 'no-cache, no-store, max-age=0',
'cf-cache-status': 'DYNAMIC',
'cf-ray': '9d5b0b137ea62c5-HAM',
'content-length': '0',
date: 'Sun, 01 Mar 2026 23:14:03 GMT',
'origin-cf-ray': '9d5bob137ea62c5-ATL',
perf: '7402827104',
server: 'cloudflare envoy',
'set-cookie': 'ct0=91771912a899; Max-Age=34214400; Expires=Thu, 01 Apr 2027 23:14:03 GMT; Path=/; Domain=.x.com; Secure; SameSite=Lax',
'strict-transport-security': 'max-age=631138519; includeSubdomains',
'x-rate-limit-limit': '50',
'x-rate-limit-remaining': '49',
'x-rate-limit-reset': '1772407743',
'x-response-time': '9',
'x-served-by': 't4_a',
'x-transaction-id': 'f9f16bd75027adF8',
'content-type': 'text/plain;charset=UTF-8'
},
body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
bodyUsed: true,
ok: false,
redirected: false,
type: 'default',
url: ''
},
data: ''
}`
open for your valuable help.
Hello all ,
I want to search tweets based on a given hashtag for my thesis project. Below is the source code, but I got error 404.
error stack is:
`> start
[dotenv@17.2.3] injecting env (16) from .env.local -- tip: 🗂️ backup and recover secrets: https://dotenvx.com/ops
Logging in...
Login successful
Searching for tweets with: #paris
Error: ApiError: Response status: 404 | headers: "cache-control: no-cache, no-store, max-age=0\ncf-cache-status: DYNAMIC\ncf-ray: 9d5bdb137eaa62c5-HAM\ncontent-length: 0\ncontent-type: text/plain;charset=UTF-8\ndate: Sun, 01 Mar 2026 23:14:03 GMT\norigin-cf-ray: 9d5bdb137eaa62c5-ATL\nperf: 7402827104\nserver: cloudflare envoy\nset-cookie: ct0=91771dff9f2bbdb26ecb65048a685753d26bc90db15285faa6146bdf9877ee090b610d45719675619168711dc0bea39f8e36da195b2912a837f6073788ed5b1ffaa280fcdebf24830fe5396d75b1c699; Max-Age=34214400; Expires=Thu, 01 Apr 2027 23:14:03 GMT; Path=/; Domain=.x.com; Secure; SameSite=Lax\nstrict-transport-security: max-age=631138519; includeSubdomains\nx-rate-limit-limit: 50\nx-rate-limit-remaining: 49\nx-rate-limit-reset: 1772407743\nx-response-time: 9\nx-served-by: t4_a\nx-transaction-id: f9f16bd75027add8" | data:
at ApiError.fromResponse (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:58:12)
at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
at async requestApi (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:575:12)
at async getSearchTimeline (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:1857:15)
at async fetchSearchTweets (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\node_modules@the-convocation\twitter-scraper\dist\node\cjs\index.cjs:1809:20)
at async main (C:\Thesis Tasks\Thesis.Scraper.Twitter_NodeJS\src\hashtag.ts:28:22) {
response: Response {
status: 404,
statusText: '',
headers: Headers {
'cache-control': 'no-cache, no-store, max-age=0',
'cf-cache-status': 'DYNAMIC',
'cf-ray': '9d5b0b137ea62c5-HAM',
'content-length': '0',
date: 'Sun, 01 Mar 2026 23:14:03 GMT',
'origin-cf-ray': '9d5bob137ea62c5-ATL',
perf: '7402827104',
server: 'cloudflare envoy',
'set-cookie': 'ct0=91771912a899; Max-Age=34214400; Expires=Thu, 01 Apr 2027 23:14:03 GMT; Path=/; Domain=.x.com; Secure; SameSite=Lax',
'strict-transport-security': 'max-age=631138519; includeSubdomains',
'x-rate-limit-limit': '50',
'x-rate-limit-remaining': '49',
'x-rate-limit-reset': '1772407743',
'x-response-time': '9',
'x-served-by': 't4_a',
'x-transaction-id': 'f9f16bd75027adF8',
'content-type': 'text/plain;charset=UTF-8'
},
body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
bodyUsed: true,
ok: false,
redirected: false,
type: 'default',
url: ''
},
data: ''
}`
open for your valuable help.