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