@the-convocation/twitter-scraper 0.17.0 → 0.17.2
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 +12 -20
- package/dist/default/cjs/index.js.map +1 -1
- package/dist/default/esm/index.mjs +12 -20
- package/dist/default/esm/index.mjs.map +1 -1
- package/dist/node/cjs/index.cjs +12 -20
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.mjs +12 -20
- package/dist/node/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/esm/index.mjs
CHANGED
|
@@ -302,12 +302,7 @@ class TwitterGuestAuth {
|
|
|
302
302
|
headers.set("cookie", await this.getCookieString());
|
|
303
303
|
}
|
|
304
304
|
async getCookies() {
|
|
305
|
-
|
|
306
|
-
this.jar.getCookies(this.getCookieJarUrl()),
|
|
307
|
-
this.jar.getCookies("https://twitter.com"),
|
|
308
|
-
this.jar.getCookies("https://x.com")
|
|
309
|
-
]);
|
|
310
|
-
return cookies.flat();
|
|
305
|
+
return this.jar.getCookies(this.getCookieJarUrl());
|
|
311
306
|
}
|
|
312
307
|
async getCookieString() {
|
|
313
308
|
const cookies = await this.getCookies();
|
|
@@ -325,7 +320,7 @@ class TwitterGuestAuth {
|
|
|
325
320
|
}
|
|
326
321
|
}
|
|
327
322
|
getCookieJarUrl() {
|
|
328
|
-
return typeof document !== "undefined" ? document.location.toString() : "https://
|
|
323
|
+
return typeof document !== "undefined" ? document.location.toString() : "https://x.com";
|
|
329
324
|
}
|
|
330
325
|
/**
|
|
331
326
|
* Updates the authentication state with a new guest token from the Twitter API.
|
|
@@ -852,7 +847,7 @@ function parseProfile(legacy, isBlueVerified) {
|
|
|
852
847
|
name: legacy.name,
|
|
853
848
|
pinnedTweetIds: legacy.pinned_tweet_ids_str,
|
|
854
849
|
tweetsCount: legacy.statuses_count,
|
|
855
|
-
url: `https://
|
|
850
|
+
url: `https://x.com/${legacy.screen_name}`,
|
|
856
851
|
userId: legacy.id_str,
|
|
857
852
|
username: legacy.screen_name,
|
|
858
853
|
isBlueVerified: isBlueVerified ?? false,
|
|
@@ -1015,7 +1010,7 @@ function parseMediaGroups(media) {
|
|
|
1015
1010
|
url: m.media_url_https,
|
|
1016
1011
|
alt_text: m.ext_alt_text
|
|
1017
1012
|
});
|
|
1018
|
-
} else if (m.type === "video") {
|
|
1013
|
+
} else if (m.type === "video" || m.type === "animated_gif") {
|
|
1019
1014
|
videos.push(parseVideo(m));
|
|
1020
1015
|
}
|
|
1021
1016
|
const sensitive = m.ext_sensitive_media_warning;
|
|
@@ -1070,22 +1065,19 @@ function reconstructTweetHtml(tweet, photos, videos) {
|
|
|
1070
1065
|
return html;
|
|
1071
1066
|
}
|
|
1072
1067
|
function linkHashtagHtml(hashtag) {
|
|
1073
|
-
return `<a href="https://
|
|
1068
|
+
return `<a href="https://x.com/hashtag/${hashtag.replace(
|
|
1074
1069
|
"#",
|
|
1075
1070
|
""
|
|
1076
1071
|
)}">${hashtag}</a>`;
|
|
1077
1072
|
}
|
|
1078
1073
|
function linkCashtagHtml(cashtag) {
|
|
1079
|
-
return `<a href="https://
|
|
1074
|
+
return `<a href="https://x.com/search?q=%24${cashtag.replace(
|
|
1080
1075
|
"$",
|
|
1081
1076
|
""
|
|
1082
1077
|
)}">${cashtag}</a>`;
|
|
1083
1078
|
}
|
|
1084
1079
|
function linkUsernameHtml(username) {
|
|
1085
|
-
return `<a href="https://
|
|
1086
|
-
"@",
|
|
1087
|
-
""
|
|
1088
|
-
)}">${username}</a>`;
|
|
1080
|
+
return `<a href="https://x.com/${username.replace("@", "")}">${username}</a>`;
|
|
1089
1081
|
}
|
|
1090
1082
|
function unwrapTcoUrlHtml(tweet, foundedMedia) {
|
|
1091
1083
|
return function(tco) {
|
|
@@ -1154,7 +1146,7 @@ function parseLegacyTweet(coreUser, user, tweet, editControl) {
|
|
|
1154
1146
|
name: mention.name
|
|
1155
1147
|
})),
|
|
1156
1148
|
name,
|
|
1157
|
-
permanentUrl: `https://
|
|
1149
|
+
permanentUrl: `https://x.com/${username}/status/${tweetId}`,
|
|
1158
1150
|
photos,
|
|
1159
1151
|
replies: tweet.reply_count,
|
|
1160
1152
|
retweets: tweet.retweet_count,
|
|
@@ -1534,7 +1526,7 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
|
|
|
1534
1526
|
params.set("fieldToggles", stringify(fieldToggles));
|
|
1535
1527
|
params.set("variables", stringify(variables));
|
|
1536
1528
|
const res = await requestApi(
|
|
1537
|
-
`https://api.
|
|
1529
|
+
`https://api.x.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
|
|
1538
1530
|
auth
|
|
1539
1531
|
);
|
|
1540
1532
|
if (!res.success) {
|
|
@@ -1649,7 +1641,7 @@ async function getFollowingTimeline(userId, maxItems, auth, cursor) {
|
|
|
1649
1641
|
params.set("features", stringify(features));
|
|
1650
1642
|
params.set("variables", stringify(variables));
|
|
1651
1643
|
const res = await requestApi(
|
|
1652
|
-
`https://
|
|
1644
|
+
`https://x.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
|
|
1653
1645
|
auth
|
|
1654
1646
|
);
|
|
1655
1647
|
if (!res.success) {
|
|
@@ -1684,7 +1676,7 @@ async function getFollowersTimeline(userId, maxItems, auth, cursor) {
|
|
|
1684
1676
|
params.set("features", stringify(features));
|
|
1685
1677
|
params.set("variables", stringify(variables));
|
|
1686
1678
|
const res = await requestApi(
|
|
1687
|
-
`https://
|
|
1679
|
+
`https://x.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
|
|
1688
1680
|
auth
|
|
1689
1681
|
);
|
|
1690
1682
|
if (!res.success) {
|
|
@@ -1701,7 +1693,7 @@ async function getTrends(auth) {
|
|
|
1701
1693
|
params.set("include_page_configuration", "false");
|
|
1702
1694
|
params.set("entity_tokens", "false");
|
|
1703
1695
|
const res = await requestApi(
|
|
1704
|
-
`https://api.
|
|
1696
|
+
`https://api.x.com/2/guide.json?${params.toString()}`,
|
|
1705
1697
|
auth
|
|
1706
1698
|
);
|
|
1707
1699
|
if (!res.success) {
|