@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/cjs/index.cjs
CHANGED
|
@@ -323,12 +323,7 @@ class TwitterGuestAuth {
|
|
|
323
323
|
headers.set("cookie", await this.getCookieString());
|
|
324
324
|
}
|
|
325
325
|
async getCookies() {
|
|
326
|
-
|
|
327
|
-
this.jar.getCookies(this.getCookieJarUrl()),
|
|
328
|
-
this.jar.getCookies("https://twitter.com"),
|
|
329
|
-
this.jar.getCookies("https://x.com")
|
|
330
|
-
]);
|
|
331
|
-
return cookies.flat();
|
|
326
|
+
return this.jar.getCookies(this.getCookieJarUrl());
|
|
332
327
|
}
|
|
333
328
|
async getCookieString() {
|
|
334
329
|
const cookies = await this.getCookies();
|
|
@@ -346,7 +341,7 @@ class TwitterGuestAuth {
|
|
|
346
341
|
}
|
|
347
342
|
}
|
|
348
343
|
getCookieJarUrl() {
|
|
349
|
-
return typeof document !== "undefined" ? document.location.toString() : "https://
|
|
344
|
+
return typeof document !== "undefined" ? document.location.toString() : "https://x.com";
|
|
350
345
|
}
|
|
351
346
|
/**
|
|
352
347
|
* Updates the authentication state with a new guest token from the Twitter API.
|
|
@@ -873,7 +868,7 @@ function parseProfile(legacy, isBlueVerified) {
|
|
|
873
868
|
name: legacy.name,
|
|
874
869
|
pinnedTweetIds: legacy.pinned_tweet_ids_str,
|
|
875
870
|
tweetsCount: legacy.statuses_count,
|
|
876
|
-
url: `https://
|
|
871
|
+
url: `https://x.com/${legacy.screen_name}`,
|
|
877
872
|
userId: legacy.id_str,
|
|
878
873
|
username: legacy.screen_name,
|
|
879
874
|
isBlueVerified: isBlueVerified ?? false,
|
|
@@ -1036,7 +1031,7 @@ function parseMediaGroups(media) {
|
|
|
1036
1031
|
url: m.media_url_https,
|
|
1037
1032
|
alt_text: m.ext_alt_text
|
|
1038
1033
|
});
|
|
1039
|
-
} else if (m.type === "video") {
|
|
1034
|
+
} else if (m.type === "video" || m.type === "animated_gif") {
|
|
1040
1035
|
videos.push(parseVideo(m));
|
|
1041
1036
|
}
|
|
1042
1037
|
const sensitive = m.ext_sensitive_media_warning;
|
|
@@ -1091,22 +1086,19 @@ function reconstructTweetHtml(tweet, photos, videos) {
|
|
|
1091
1086
|
return html;
|
|
1092
1087
|
}
|
|
1093
1088
|
function linkHashtagHtml(hashtag) {
|
|
1094
|
-
return `<a href="https://
|
|
1089
|
+
return `<a href="https://x.com/hashtag/${hashtag.replace(
|
|
1095
1090
|
"#",
|
|
1096
1091
|
""
|
|
1097
1092
|
)}">${hashtag}</a>`;
|
|
1098
1093
|
}
|
|
1099
1094
|
function linkCashtagHtml(cashtag) {
|
|
1100
|
-
return `<a href="https://
|
|
1095
|
+
return `<a href="https://x.com/search?q=%24${cashtag.replace(
|
|
1101
1096
|
"$",
|
|
1102
1097
|
""
|
|
1103
1098
|
)}">${cashtag}</a>`;
|
|
1104
1099
|
}
|
|
1105
1100
|
function linkUsernameHtml(username) {
|
|
1106
|
-
return `<a href="https://
|
|
1107
|
-
"@",
|
|
1108
|
-
""
|
|
1109
|
-
)}">${username}</a>`;
|
|
1101
|
+
return `<a href="https://x.com/${username.replace("@", "")}">${username}</a>`;
|
|
1110
1102
|
}
|
|
1111
1103
|
function unwrapTcoUrlHtml(tweet, foundedMedia) {
|
|
1112
1104
|
return function(tco) {
|
|
@@ -1175,7 +1167,7 @@ function parseLegacyTweet(coreUser, user, tweet, editControl) {
|
|
|
1175
1167
|
name: mention.name
|
|
1176
1168
|
})),
|
|
1177
1169
|
name,
|
|
1178
|
-
permanentUrl: `https://
|
|
1170
|
+
permanentUrl: `https://x.com/${username}/status/${tweetId}`,
|
|
1179
1171
|
photos,
|
|
1180
1172
|
replies: tweet.reply_count,
|
|
1181
1173
|
retweets: tweet.retweet_count,
|
|
@@ -1555,7 +1547,7 @@ async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
|
|
|
1555
1547
|
params.set("fieldToggles", stringify(fieldToggles));
|
|
1556
1548
|
params.set("variables", stringify(variables));
|
|
1557
1549
|
const res = await requestApi(
|
|
1558
|
-
`https://api.
|
|
1550
|
+
`https://api.x.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`,
|
|
1559
1551
|
auth
|
|
1560
1552
|
);
|
|
1561
1553
|
if (!res.success) {
|
|
@@ -1670,7 +1662,7 @@ async function getFollowingTimeline(userId, maxItems, auth, cursor) {
|
|
|
1670
1662
|
params.set("features", stringify(features));
|
|
1671
1663
|
params.set("variables", stringify(variables));
|
|
1672
1664
|
const res = await requestApi(
|
|
1673
|
-
`https://
|
|
1665
|
+
`https://x.com/i/api/graphql/iSicc7LrzWGBgDPL0tM_TQ/Following?${params.toString()}`,
|
|
1674
1666
|
auth
|
|
1675
1667
|
);
|
|
1676
1668
|
if (!res.success) {
|
|
@@ -1705,7 +1697,7 @@ async function getFollowersTimeline(userId, maxItems, auth, cursor) {
|
|
|
1705
1697
|
params.set("features", stringify(features));
|
|
1706
1698
|
params.set("variables", stringify(variables));
|
|
1707
1699
|
const res = await requestApi(
|
|
1708
|
-
`https://
|
|
1700
|
+
`https://x.com/i/api/graphql/rRXFSG5vR6drKr5M37YOTw/Followers?${params.toString()}`,
|
|
1709
1701
|
auth
|
|
1710
1702
|
);
|
|
1711
1703
|
if (!res.success) {
|
|
@@ -1722,7 +1714,7 @@ async function getTrends(auth) {
|
|
|
1722
1714
|
params.set("include_page_configuration", "false");
|
|
1723
1715
|
params.set("entity_tokens", "false");
|
|
1724
1716
|
const res = await requestApi(
|
|
1725
|
-
`https://api.
|
|
1717
|
+
`https://api.x.com/2/guide.json?${params.toString()}`,
|
|
1726
1718
|
auth
|
|
1727
1719
|
);
|
|
1728
1720
|
if (!res.success) {
|