@the-convocation/twitter-scraper 0.22.1 → 0.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/default/cjs/index.js +20 -5
- package/dist/default/cjs/index.js.map +1 -1
- package/dist/default/esm/index.mjs +20 -5
- package/dist/default/esm/index.mjs.map +1 -1
- package/dist/node/cjs/index.cjs +20 -5
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.mjs +20 -5
- package/dist/node/esm/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1367,7 +1367,7 @@ async function jitter(maxMs) {
|
|
|
1367
1367
|
const jitter2 = Math.random() * maxMs;
|
|
1368
1368
|
await new Promise((resolve) => setTimeout(resolve, jitter2));
|
|
1369
1369
|
}
|
|
1370
|
-
async function requestApi(url, auth, method = "GET", platform = new Platform(), headers = new headersPolyfill.Headers(), bearerTokenOverride) {
|
|
1370
|
+
async function requestApi(url, auth, method = "GET", platform = new Platform(), headers = new headersPolyfill.Headers(), bearerTokenOverride, body) {
|
|
1371
1371
|
log$2(`Making ${method} request to ${url}`);
|
|
1372
1372
|
await auth.installTo(headers, url, bearerTokenOverride);
|
|
1373
1373
|
await platform.randomizeCiphers();
|
|
@@ -1379,6 +1379,9 @@ async function requestApi(url, auth, method = "GET", platform = new Platform(),
|
|
|
1379
1379
|
);
|
|
1380
1380
|
headers.set("x-client-transaction-id", transactionId);
|
|
1381
1381
|
}
|
|
1382
|
+
if (body && method === "POST") {
|
|
1383
|
+
headers.set("content-type", "application/json");
|
|
1384
|
+
}
|
|
1382
1385
|
let res;
|
|
1383
1386
|
do {
|
|
1384
1387
|
const fetchParameters = [
|
|
@@ -1386,7 +1389,8 @@ async function requestApi(url, auth, method = "GET", platform = new Platform(),
|
|
|
1386
1389
|
{
|
|
1387
1390
|
method,
|
|
1388
1391
|
headers,
|
|
1389
|
-
credentials: "include"
|
|
1392
|
+
credentials: "include",
|
|
1393
|
+
...body && method === "POST" ? { body: JSON.stringify(body) } : {}
|
|
1390
1394
|
}
|
|
1391
1395
|
];
|
|
1392
1396
|
try {
|
|
@@ -2239,6 +2243,16 @@ class ApiRequest {
|
|
|
2239
2243
|
}
|
|
2240
2244
|
return `${this.url}?${params.toString()}`;
|
|
2241
2245
|
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Converts the request into a JSON body for POST requests.
|
|
2248
|
+
*/
|
|
2249
|
+
toRequestBody() {
|
|
2250
|
+
const body = {};
|
|
2251
|
+
if (this.variables) body.variables = this.variables;
|
|
2252
|
+
if (this.features) body.features = this.features;
|
|
2253
|
+
if (this.fieldToggles) body.fieldToggles = this.fieldToggles;
|
|
2254
|
+
return body;
|
|
2255
|
+
}
|
|
2242
2256
|
}
|
|
2243
2257
|
function parseEndpointExample(example) {
|
|
2244
2258
|
const { protocol, host, pathname, searchParams: query } = new URL(example);
|
|
@@ -2972,12 +2986,13 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
|
|
|
2972
2986
|
break;
|
|
2973
2987
|
}
|
|
2974
2988
|
const res = await requestApi(
|
|
2975
|
-
searchTimelineRequest.
|
|
2989
|
+
searchTimelineRequest.url,
|
|
2976
2990
|
auth,
|
|
2977
|
-
"
|
|
2991
|
+
"POST",
|
|
2978
2992
|
void 0,
|
|
2979
2993
|
void 0,
|
|
2980
|
-
bearerToken2
|
|
2994
|
+
bearerToken2,
|
|
2995
|
+
searchTimelineRequest.toRequestBody()
|
|
2981
2996
|
);
|
|
2982
2997
|
if (!res.success) {
|
|
2983
2998
|
throw res.err;
|