@the-convocation/twitter-scraper 0.22.2 → 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 +1 -1
|
@@ -1346,7 +1346,7 @@ async function jitter(maxMs) {
|
|
|
1346
1346
|
const jitter2 = Math.random() * maxMs;
|
|
1347
1347
|
await new Promise((resolve) => setTimeout(resolve, jitter2));
|
|
1348
1348
|
}
|
|
1349
|
-
async function requestApi(url, auth, method = "GET", platform = new Platform(), headers = new Headers(), bearerTokenOverride) {
|
|
1349
|
+
async function requestApi(url, auth, method = "GET", platform = new Platform(), headers = new Headers(), bearerTokenOverride, body) {
|
|
1350
1350
|
log$2(`Making ${method} request to ${url}`);
|
|
1351
1351
|
await auth.installTo(headers, url, bearerTokenOverride);
|
|
1352
1352
|
await platform.randomizeCiphers();
|
|
@@ -1358,6 +1358,9 @@ async function requestApi(url, auth, method = "GET", platform = new Platform(),
|
|
|
1358
1358
|
);
|
|
1359
1359
|
headers.set("x-client-transaction-id", transactionId);
|
|
1360
1360
|
}
|
|
1361
|
+
if (body && method === "POST") {
|
|
1362
|
+
headers.set("content-type", "application/json");
|
|
1363
|
+
}
|
|
1361
1364
|
let res;
|
|
1362
1365
|
do {
|
|
1363
1366
|
const fetchParameters = [
|
|
@@ -1365,7 +1368,8 @@ async function requestApi(url, auth, method = "GET", platform = new Platform(),
|
|
|
1365
1368
|
{
|
|
1366
1369
|
method,
|
|
1367
1370
|
headers,
|
|
1368
|
-
credentials: "include"
|
|
1371
|
+
credentials: "include",
|
|
1372
|
+
...body && method === "POST" ? { body: JSON.stringify(body) } : {}
|
|
1369
1373
|
}
|
|
1370
1374
|
];
|
|
1371
1375
|
try {
|
|
@@ -2218,6 +2222,16 @@ class ApiRequest {
|
|
|
2218
2222
|
}
|
|
2219
2223
|
return `${this.url}?${params.toString()}`;
|
|
2220
2224
|
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Converts the request into a JSON body for POST requests.
|
|
2227
|
+
*/
|
|
2228
|
+
toRequestBody() {
|
|
2229
|
+
const body = {};
|
|
2230
|
+
if (this.variables) body.variables = this.variables;
|
|
2231
|
+
if (this.features) body.features = this.features;
|
|
2232
|
+
if (this.fieldToggles) body.fieldToggles = this.fieldToggles;
|
|
2233
|
+
return body;
|
|
2234
|
+
}
|
|
2221
2235
|
}
|
|
2222
2236
|
function parseEndpointExample(example) {
|
|
2223
2237
|
const { protocol, host, pathname, searchParams: query } = new URL(example);
|
|
@@ -2951,12 +2965,13 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
|
|
|
2951
2965
|
break;
|
|
2952
2966
|
}
|
|
2953
2967
|
const res = await requestApi(
|
|
2954
|
-
searchTimelineRequest.
|
|
2968
|
+
searchTimelineRequest.url,
|
|
2955
2969
|
auth,
|
|
2956
|
-
"
|
|
2970
|
+
"POST",
|
|
2957
2971
|
void 0,
|
|
2958
2972
|
void 0,
|
|
2959
|
-
bearerToken2
|
|
2973
|
+
bearerToken2,
|
|
2974
|
+
searchTimelineRequest.toRequestBody()
|
|
2960
2975
|
);
|
|
2961
2976
|
if (!res.success) {
|
|
2962
2977
|
throw res.err;
|