@the-convocation/twitter-scraper 0.13.0 → 0.14.0
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/README.md +71 -38
- package/dist/default/cjs/index.js +2126 -0
- package/dist/default/cjs/index.js.map +1 -0
- package/dist/default/esm/index.mjs +2104 -0
- package/dist/default/esm/index.mjs.map +1 -0
- package/dist/node/cjs/index.cjs +2156 -0
- package/dist/node/cjs/index.cjs.map +1 -0
- package/dist/node/esm/index.mjs +2134 -0
- package/dist/node/esm/index.mjs.map +1 -0
- package/dist/{scraper.d.ts → types/index.d.ts} +284 -8
- package/examples/cors-proxy/package.json +18 -0
- package/examples/node-integration/package.json +12 -0
- package/examples/react-integration/README.md +30 -0
- package/examples/react-integration/index.html +13 -0
- package/examples/react-integration/package.json +29 -0
- package/examples/react-integration/public/vite.svg +1 -0
- package/examples/react-integration/tsconfig.node.json +11 -0
- package/examples/react-integration/vite.config.ts +7 -0
- package/package.json +20 -3
- package/rollup.config.mjs +61 -0
- package/test-setup.js +2 -0
- package/dist/_module.d.ts +0 -6
- package/dist/_module.d.ts.map +0 -1
- package/dist/_module.js +0 -8
- package/dist/_module.js.map +0 -1
- package/dist/api-data.d.ts +0 -47
- package/dist/api-data.d.ts.map +0 -1
- package/dist/api-data.js +0 -84
- package/dist/api-data.js.map +0 -1
- package/dist/api.d.ts +0 -32
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -138
- package/dist/api.js.map +0 -1
- package/dist/auth-user.d.ts +0 -23
- package/dist/auth-user.d.ts.map +0 -1
- package/dist/auth-user.js +0 -290
- package/dist/auth-user.js.map +0 -1
- package/dist/auth.d.ts +0 -82
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -122
- package/dist/auth.js.map +0 -1
- package/dist/errors.d.ts +0 -28
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -26
- package/dist/errors.js.map +0 -1
- package/dist/profile.d.ts +0 -80
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -127
- package/dist/profile.js.map +0 -1
- package/dist/relationships.d.ts +0 -8
- package/dist/relationships.d.ts.map +0 -1
- package/dist/relationships.js +0 -93
- package/dist/relationships.js.map +0 -1
- package/dist/requests.d.ts +0 -9
- package/dist/requests.d.ts.map +0 -1
- package/dist/requests.js +0 -26
- package/dist/requests.js.map +0 -1
- package/dist/scraper.d.ts.map +0 -1
- package/dist/scraper.js +0 -357
- package/dist/scraper.js.map +0 -1
- package/dist/search.d.ts +0 -19
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js +0 -99
- package/dist/search.js.map +0 -1
- package/dist/timeline-async.d.ts +0 -15
- package/dist/timeline-async.d.ts.map +0 -1
- package/dist/timeline-async.js +0 -53
- package/dist/timeline-async.js.map +0 -1
- package/dist/timeline-list.d.ts +0 -19
- package/dist/timeline-list.d.ts.map +0 -1
- package/dist/timeline-list.js +0 -46
- package/dist/timeline-list.js.map +0 -1
- package/dist/timeline-relationship.d.ts +0 -39
- package/dist/timeline-relationship.d.ts.map +0 -1
- package/dist/timeline-relationship.js +0 -46
- package/dist/timeline-relationship.js.map +0 -1
- package/dist/timeline-search.d.ts +0 -20
- package/dist/timeline-search.d.ts.map +0 -1
- package/dist/timeline-search.js +0 -93
- package/dist/timeline-search.js.map +0 -1
- package/dist/timeline-tweet-util.d.ts +0 -9
- package/dist/timeline-tweet-util.d.ts.map +0 -1
- package/dist/timeline-tweet-util.js +0 -108
- package/dist/timeline-tweet-util.js.map +0 -1
- package/dist/timeline-v1.d.ts +0 -233
- package/dist/timeline-v1.d.ts.map +0 -1
- package/dist/timeline-v1.js +0 -197
- package/dist/timeline-v1.js.map +0 -1
- package/dist/timeline-v2.d.ts +0 -94
- package/dist/timeline-v2.d.ts.map +0 -1
- package/dist/timeline-v2.js +0 -253
- package/dist/timeline-v2.js.map +0 -1
- package/dist/trends.d.ts +0 -3
- package/dist/trends.d.ts.map +0 -1
- package/dist/trends.js +0 -39
- package/dist/trends.js.map +0 -1
- package/dist/tweets.d.ts +0 -117
- package/dist/tweets.d.ts.map +0 -1
- package/dist/tweets.js +0 -202
- package/dist/tweets.js.map +0 -1
- package/dist/type-util.d.ts +0 -6
- package/dist/type-util.d.ts.map +0 -1
- package/dist/type-util.js +0 -14
- package/dist/type-util.js.map +0 -1
package/dist/requests.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.updateCookieJar = void 0;
|
|
7
|
-
const tough_cookie_1 = require("tough-cookie");
|
|
8
|
-
const set_cookie_parser_1 = __importDefault(require("set-cookie-parser"));
|
|
9
|
-
/**
|
|
10
|
-
* Updates a cookie jar with the Set-Cookie headers from the provided Headers instance.
|
|
11
|
-
* @param cookieJar The cookie jar to update.
|
|
12
|
-
* @param headers The response headers to populate the cookie jar with.
|
|
13
|
-
*/
|
|
14
|
-
async function updateCookieJar(cookieJar, headers) {
|
|
15
|
-
const setCookieHeader = headers.get('set-cookie');
|
|
16
|
-
if (setCookieHeader) {
|
|
17
|
-
const cookies = set_cookie_parser_1.default.splitCookiesString(setCookieHeader);
|
|
18
|
-
for (const cookie of cookies.map((c) => tough_cookie_1.Cookie.parse(c))) {
|
|
19
|
-
if (!cookie)
|
|
20
|
-
continue;
|
|
21
|
-
await cookieJar.setCookie(cookie, `${cookie.secure ? 'https' : 'http'}://${cookie.domain}${cookie.path}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.updateCookieJar = updateCookieJar;
|
|
26
|
-
//# sourceMappingURL=requests.js.map
|
package/dist/requests.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../src/requests.ts"],"names":[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MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,EAC5B,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,KAAK,EAAE,CAAC;IAInB;;;;;OAKG;IACI,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,eAAe,UAAQ,EACvB,GAAG,SAAM,GACR,OAAO,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IAI/B;;;;OAIG;IACI,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAQlD;;;OAGG;IACI,aAAa,IAAI,OAAO;IAI/B;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAM3C;;;;;;;OAOG;IACU,KAAK,CAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;IAQhB;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI5C;;;OAGG;IACU,UAAU,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpE;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1C;;;;;OAKG;IAEI,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAO3C;;;;;OAKG;IAEI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAO9C,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;CAOvB"}
|
package/dist/scraper.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Scraper = void 0;
|
|
4
|
-
const api_1 = require("./api");
|
|
5
|
-
const auth_1 = require("./auth");
|
|
6
|
-
const auth_user_1 = require("./auth-user");
|
|
7
|
-
const profile_1 = require("./profile");
|
|
8
|
-
const search_1 = require("./search");
|
|
9
|
-
const relationships_1 = require("./relationships");
|
|
10
|
-
const trends_1 = require("./trends");
|
|
11
|
-
const tweets_1 = require("./tweets");
|
|
12
|
-
const twUrl = 'https://twitter.com';
|
|
13
|
-
/**
|
|
14
|
-
* An interface to Twitter's undocumented API.
|
|
15
|
-
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
16
|
-
*/
|
|
17
|
-
class Scraper {
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new Scraper object.
|
|
20
|
-
* - Scrapers maintain their own guest tokens for Twitter's internal API.
|
|
21
|
-
* - Reusing Scraper objects is recommended to minimize the time spent authenticating unnecessarily.
|
|
22
|
-
*/
|
|
23
|
-
constructor(options) {
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.token = api_1.bearerToken;
|
|
26
|
-
this.useGuestAuth();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Initializes auth properties using a guest token.
|
|
30
|
-
* Used when creating a new instance of this class, and when logging out.
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
useGuestAuth() {
|
|
34
|
-
this.auth = new auth_1.TwitterGuestAuth(this.token, this.getAuthOptions());
|
|
35
|
-
this.authTrends = new auth_1.TwitterGuestAuth(this.token, this.getAuthOptions());
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Fetches a Twitter profile.
|
|
39
|
-
* @param username The Twitter username of the profile to fetch, without an `@` at the beginning.
|
|
40
|
-
* @returns The requested {@link Profile}.
|
|
41
|
-
*/
|
|
42
|
-
async getProfile(username) {
|
|
43
|
-
const res = await (0, profile_1.getProfile)(username, this.auth);
|
|
44
|
-
return this.handleResponse(res);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Fetches the user ID corresponding to the provided screen name.
|
|
48
|
-
* @param screenName The Twitter screen name of the profile to fetch.
|
|
49
|
-
* @returns The ID of the corresponding account.
|
|
50
|
-
*/
|
|
51
|
-
async getUserIdByScreenName(screenName) {
|
|
52
|
-
const res = await (0, profile_1.getUserIdByScreenName)(screenName, this.auth);
|
|
53
|
-
return this.handleResponse(res);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Fetches tweets from Twitter.
|
|
57
|
-
* @param query The search query. Any Twitter-compatible query format can be used.
|
|
58
|
-
* @param maxTweets The maximum number of tweets to return.
|
|
59
|
-
* @param includeReplies Whether or not replies should be included in the response.
|
|
60
|
-
* @param searchMode The category filter to apply to the search. Defaults to `Top`.
|
|
61
|
-
* @returns An {@link AsyncGenerator} of tweets matching the provided filters.
|
|
62
|
-
*/
|
|
63
|
-
searchTweets(query, maxTweets, searchMode = search_1.SearchMode.Top) {
|
|
64
|
-
return (0, search_1.searchTweets)(query, maxTweets, searchMode, this.auth);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Fetches profiles from Twitter.
|
|
68
|
-
* @param query The search query. Any Twitter-compatible query format can be used.
|
|
69
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
70
|
-
* @returns An {@link AsyncGenerator} of tweets matching the provided filter(s).
|
|
71
|
-
*/
|
|
72
|
-
searchProfiles(query, maxProfiles) {
|
|
73
|
-
return (0, search_1.searchProfiles)(query, maxProfiles, this.auth);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Fetches tweets from Twitter.
|
|
77
|
-
* @param query The search query. Any Twitter-compatible query format can be used.
|
|
78
|
-
* @param maxTweets The maximum number of tweets to return.
|
|
79
|
-
* @param includeReplies Whether or not replies should be included in the response.
|
|
80
|
-
* @param searchMode The category filter to apply to the search. Defaults to `Top`.
|
|
81
|
-
* @param cursor The search cursor, which can be passed into further requests for more results.
|
|
82
|
-
* @returns A page of results, containing a cursor that can be used in further requests.
|
|
83
|
-
*/
|
|
84
|
-
fetchSearchTweets(query, maxTweets, searchMode, cursor) {
|
|
85
|
-
return (0, search_1.fetchSearchTweets)(query, maxTweets, searchMode, this.auth, cursor);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Fetches profiles from Twitter.
|
|
89
|
-
* @param query The search query. Any Twitter-compatible query format can be used.
|
|
90
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
91
|
-
* @param cursor The search cursor, which can be passed into further requests for more results.
|
|
92
|
-
* @returns A page of results, containing a cursor that can be used in further requests.
|
|
93
|
-
*/
|
|
94
|
-
fetchSearchProfiles(query, maxProfiles, cursor) {
|
|
95
|
-
return (0, search_1.fetchSearchProfiles)(query, maxProfiles, this.auth, cursor);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Fetches list tweets from Twitter.
|
|
99
|
-
* @param listId The list id
|
|
100
|
-
* @param maxTweets The maximum number of tweets to return.
|
|
101
|
-
* @param cursor The search cursor, which can be passed into further requests for more results.
|
|
102
|
-
* @returns A page of results, containing a cursor that can be used in further requests.
|
|
103
|
-
*/
|
|
104
|
-
fetchListTweets(listId, maxTweets, cursor) {
|
|
105
|
-
return (0, tweets_1.fetchListTweets)(listId, maxTweets, cursor, this.auth);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Fetch the profiles a user is following
|
|
109
|
-
* @param userId The user whose following should be returned
|
|
110
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
111
|
-
* @returns An {@link AsyncGenerator} of following profiles for the provided user.
|
|
112
|
-
*/
|
|
113
|
-
getFollowing(userId, maxProfiles) {
|
|
114
|
-
return (0, relationships_1.getFollowing)(userId, maxProfiles, this.auth);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Fetch the profiles that follow a user
|
|
118
|
-
* @param userId The user whose followers should be returned
|
|
119
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
120
|
-
* @returns An {@link AsyncGenerator} of profiles following the provided user.
|
|
121
|
-
*/
|
|
122
|
-
getFollowers(userId, maxProfiles) {
|
|
123
|
-
return (0, relationships_1.getFollowers)(userId, maxProfiles, this.auth);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Fetches following profiles from Twitter.
|
|
127
|
-
* @param userId The user whose following should be returned
|
|
128
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
129
|
-
* @param cursor The search cursor, which can be passed into further requests for more results.
|
|
130
|
-
* @returns A page of results, containing a cursor that can be used in further requests.
|
|
131
|
-
*/
|
|
132
|
-
fetchProfileFollowing(userId, maxProfiles, cursor) {
|
|
133
|
-
return (0, relationships_1.fetchProfileFollowing)(userId, maxProfiles, this.auth, cursor);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Fetches profile followers from Twitter.
|
|
137
|
-
* @param userId The user whose following should be returned
|
|
138
|
-
* @param maxProfiles The maximum number of profiles to return.
|
|
139
|
-
* @param cursor The search cursor, which can be passed into further requests for more results.
|
|
140
|
-
* @returns A page of results, containing a cursor that can be used in further requests.
|
|
141
|
-
*/
|
|
142
|
-
fetchProfileFollowers(userId, maxProfiles, cursor) {
|
|
143
|
-
return (0, relationships_1.fetchProfileFollowers)(userId, maxProfiles, this.auth, cursor);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Fetches the current trends from Twitter.
|
|
147
|
-
* @returns The current list of trends.
|
|
148
|
-
*/
|
|
149
|
-
getTrends() {
|
|
150
|
-
return (0, trends_1.getTrends)(this.authTrends);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Fetches tweets from a Twitter user.
|
|
154
|
-
* @param user The user whose tweets should be returned.
|
|
155
|
-
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
|
|
156
|
-
* @returns An {@link AsyncGenerator} of tweets from the provided user.
|
|
157
|
-
*/
|
|
158
|
-
getTweets(user, maxTweets = 200) {
|
|
159
|
-
return (0, tweets_1.getTweets)(user, maxTweets, this.auth);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Fetches liked tweets from a Twitter user. Requires authentication.
|
|
163
|
-
* @param user The user whose likes should be returned.
|
|
164
|
-
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
|
|
165
|
-
* @returns An {@link AsyncGenerator} of liked tweets from the provided user.
|
|
166
|
-
*/
|
|
167
|
-
getLikedTweets(user, maxTweets = 200) {
|
|
168
|
-
return (0, tweets_1.getLikedTweets)(user, maxTweets, this.auth);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Fetches tweets from a Twitter user using their ID.
|
|
172
|
-
* @param userId The user whose tweets should be returned.
|
|
173
|
-
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
|
|
174
|
-
* @returns An {@link AsyncGenerator} of tweets from the provided user.
|
|
175
|
-
*/
|
|
176
|
-
getTweetsByUserId(userId, maxTweets = 200) {
|
|
177
|
-
return (0, tweets_1.getTweetsByUserId)(userId, maxTweets, this.auth);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Fetches tweets and replies from a Twitter user.
|
|
181
|
-
* @param user The user whose tweets should be returned.
|
|
182
|
-
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
|
|
183
|
-
* @returns An {@link AsyncGenerator} of tweets from the provided user.
|
|
184
|
-
*/
|
|
185
|
-
getTweetsAndReplies(user, maxTweets = 200) {
|
|
186
|
-
return (0, tweets_1.getTweetsAndReplies)(user, maxTweets, this.auth);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Fetches tweets and replies from a Twitter user using their ID.
|
|
190
|
-
* @param userId The user whose tweets should be returned.
|
|
191
|
-
* @param maxTweets The maximum number of tweets to return. Defaults to `200`.
|
|
192
|
-
* @returns An {@link AsyncGenerator} of tweets from the provided user.
|
|
193
|
-
*/
|
|
194
|
-
getTweetsAndRepliesByUserId(userId, maxTweets = 200) {
|
|
195
|
-
return (0, tweets_1.getTweetsAndRepliesByUserId)(userId, maxTweets, this.auth);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Fetches the first tweet matching the given query.
|
|
199
|
-
*
|
|
200
|
-
* Example:
|
|
201
|
-
* ```js
|
|
202
|
-
* const timeline = scraper.getTweets('user', 200);
|
|
203
|
-
* const retweet = await scraper.getTweetWhere(timeline, { isRetweet: true });
|
|
204
|
-
* ```
|
|
205
|
-
* @param tweets The {@link AsyncIterable} of tweets to search through.
|
|
206
|
-
* @param query A query to test **all** tweets against. This may be either an
|
|
207
|
-
* object of key/value pairs or a predicate. If this query is an object, all
|
|
208
|
-
* key/value pairs must match a {@link Tweet} for it to be returned. If this query
|
|
209
|
-
* is a predicate, it must resolve to `true` for a {@link Tweet} to be returned.
|
|
210
|
-
* - All keys are optional.
|
|
211
|
-
* - If specified, the key must be implemented by that of {@link Tweet}.
|
|
212
|
-
*/
|
|
213
|
-
getTweetWhere(tweets, query) {
|
|
214
|
-
return (0, tweets_1.getTweetWhere)(tweets, query);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Fetches all tweets matching the given query.
|
|
218
|
-
*
|
|
219
|
-
* Example:
|
|
220
|
-
* ```js
|
|
221
|
-
* const timeline = scraper.getTweets('user', 200);
|
|
222
|
-
* const retweets = await scraper.getTweetsWhere(timeline, { isRetweet: true });
|
|
223
|
-
* ```
|
|
224
|
-
* @param tweets The {@link AsyncIterable} of tweets to search through.
|
|
225
|
-
* @param query A query to test **all** tweets against. This may be either an
|
|
226
|
-
* object of key/value pairs or a predicate. If this query is an object, all
|
|
227
|
-
* key/value pairs must match a {@link Tweet} for it to be returned. If this query
|
|
228
|
-
* is a predicate, it must resolve to `true` for a {@link Tweet} to be returned.
|
|
229
|
-
* - All keys are optional.
|
|
230
|
-
* - If specified, the key must be implemented by that of {@link Tweet}.
|
|
231
|
-
*/
|
|
232
|
-
getTweetsWhere(tweets, query) {
|
|
233
|
-
return (0, tweets_1.getTweetsWhere)(tweets, query);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Fetches the most recent tweet from a Twitter user.
|
|
237
|
-
* @param user The user whose latest tweet should be returned.
|
|
238
|
-
* @param includeRetweets Whether or not to include retweets. Defaults to `false`.
|
|
239
|
-
* @returns The {@link Tweet} object or `null`/`undefined` if it couldn't be fetched.
|
|
240
|
-
*/
|
|
241
|
-
getLatestTweet(user, includeRetweets = false, max = 200) {
|
|
242
|
-
return (0, tweets_1.getLatestTweet)(user, includeRetweets, max, this.auth);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Fetches a single tweet.
|
|
246
|
-
* @param id The ID of the tweet to fetch.
|
|
247
|
-
* @returns The {@link Tweet} object, or `null` if it couldn't be fetched.
|
|
248
|
-
*/
|
|
249
|
-
getTweet(id) {
|
|
250
|
-
if (this.auth instanceof auth_user_1.TwitterUserAuth) {
|
|
251
|
-
return (0, tweets_1.getTweet)(id, this.auth);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
return (0, tweets_1.getTweetAnonymous)(id, this.auth);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Returns if the scraper has a guest token. The token may not be valid.
|
|
259
|
-
* @returns `true` if the scraper has a guest token; otherwise `false`.
|
|
260
|
-
*/
|
|
261
|
-
hasGuestToken() {
|
|
262
|
-
return this.auth.hasToken() || this.authTrends.hasToken();
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Returns if the scraper is logged in as a real user.
|
|
266
|
-
* @returns `true` if the scraper is logged in with a real user account; otherwise `false`.
|
|
267
|
-
*/
|
|
268
|
-
async isLoggedIn() {
|
|
269
|
-
return ((await this.auth.isLoggedIn()) && (await this.authTrends.isLoggedIn()));
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Login to Twitter as a real Twitter account. This enables running
|
|
273
|
-
* searches.
|
|
274
|
-
* @param username The username of the Twitter account to login with.
|
|
275
|
-
* @param password The password of the Twitter account to login with.
|
|
276
|
-
* @param email The email to log in with, if you have email confirmation enabled.
|
|
277
|
-
* @param twoFactorSecret The secret to generate two factor authentication tokens with, if you have two factor authentication enabled.
|
|
278
|
-
*/
|
|
279
|
-
async login(username, password, email, twoFactorSecret) {
|
|
280
|
-
// Swap in a real authorizer for all requests
|
|
281
|
-
const userAuth = new auth_user_1.TwitterUserAuth(this.token, this.getAuthOptions());
|
|
282
|
-
await userAuth.login(username, password, email, twoFactorSecret);
|
|
283
|
-
this.auth = userAuth;
|
|
284
|
-
this.authTrends = userAuth;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Log out of Twitter.
|
|
288
|
-
*/
|
|
289
|
-
async logout() {
|
|
290
|
-
await this.auth.logout();
|
|
291
|
-
await this.authTrends.logout();
|
|
292
|
-
// Swap in guest authorizers for all requests
|
|
293
|
-
this.useGuestAuth();
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Retrieves all cookies for the current session.
|
|
297
|
-
* @returns All cookies for the current session.
|
|
298
|
-
*/
|
|
299
|
-
async getCookies() {
|
|
300
|
-
return await this.authTrends.cookieJar().getCookies(twUrl);
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Set cookies for the current session.
|
|
304
|
-
* @param cookies The cookies to set for the current session.
|
|
305
|
-
*/
|
|
306
|
-
async setCookies(cookies) {
|
|
307
|
-
const userAuth = new auth_user_1.TwitterUserAuth(this.token, this.getAuthOptions());
|
|
308
|
-
for (const cookie of cookies) {
|
|
309
|
-
await userAuth.cookieJar().setCookie(cookie, twUrl);
|
|
310
|
-
}
|
|
311
|
-
this.auth = userAuth;
|
|
312
|
-
this.authTrends = userAuth;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Clear all cookies for the current session.
|
|
316
|
-
*/
|
|
317
|
-
async clearCookies() {
|
|
318
|
-
await this.auth.cookieJar().removeAllCookies();
|
|
319
|
-
await this.authTrends.cookieJar().removeAllCookies();
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Sets the optional cookie to be used in requests.
|
|
323
|
-
* @param _cookie The cookie to be used in requests.
|
|
324
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
325
|
-
* @returns This scraper instance.
|
|
326
|
-
*/
|
|
327
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
328
|
-
withCookie(_cookie) {
|
|
329
|
-
console.warn('Warning: Scraper#withCookie is deprecated and will be removed in a later version. Use Scraper#login or Scraper#setCookies instead.');
|
|
330
|
-
return this;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Sets the optional CSRF token to be used in requests.
|
|
334
|
-
* @param _token The CSRF token to be used in requests.
|
|
335
|
-
* @deprecated This function no longer represents any part of Twitter's auth flow.
|
|
336
|
-
* @returns This scraper instance.
|
|
337
|
-
*/
|
|
338
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
339
|
-
withXCsrfToken(_token) {
|
|
340
|
-
console.warn('Warning: Scraper#withXCsrfToken is deprecated and will be removed in a later version.');
|
|
341
|
-
return this;
|
|
342
|
-
}
|
|
343
|
-
getAuthOptions() {
|
|
344
|
-
return {
|
|
345
|
-
fetch: this.options?.fetch,
|
|
346
|
-
transform: this.options?.transform,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
handleResponse(res) {
|
|
350
|
-
if (!res.success) {
|
|
351
|
-
throw res.err;
|
|
352
|
-
}
|
|
353
|
-
return res.value;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
exports.Scraper = Scraper;
|
|
357
|
-
//# sourceMappingURL=scraper.js.map
|
package/dist/scraper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scraper.js","sourceRoot":"","sources":["../src/scraper.ts"],"names":[],"mappings":";;;AACA,+BAA6E;AAC7E,iCAA2E;AAC3E,2CAA8C;AAC9C,uCAAuE;AACvE,qCAMkB;AAClB,mDAKyB;AAEzB,qCAAqC;AACrC,qCAckB;AAGlB,MAAM,KAAK,GAAG,qBAAq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AC;IACJ,CAAC;IAEO,cAAc,CAAI,GAAwB;QAChD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,MAAM,GAAG,CAAC,GAAG,CAAC;SACf;QAED,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;CACF;AAxbD,0BAwbC"}
|
package/dist/search.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { TwitterAuth } from './auth';
|
|
2
|
-
import { Profile } from './profile';
|
|
3
|
-
import { QueryProfilesResponse, QueryTweetsResponse } from './timeline-v1';
|
|
4
|
-
import { Tweet } from './tweets';
|
|
5
|
-
/**
|
|
6
|
-
* The categories that can be used in Twitter searches.
|
|
7
|
-
*/
|
|
8
|
-
export declare enum SearchMode {
|
|
9
|
-
Top = 0,
|
|
10
|
-
Latest = 1,
|
|
11
|
-
Photos = 2,
|
|
12
|
-
Videos = 3,
|
|
13
|
-
Users = 4
|
|
14
|
-
}
|
|
15
|
-
export declare function searchTweets(query: string, maxTweets: number, searchMode: SearchMode, auth: TwitterAuth): AsyncGenerator<Tweet, void>;
|
|
16
|
-
export declare function searchProfiles(query: string, maxProfiles: number, auth: TwitterAuth): AsyncGenerator<Profile, void>;
|
|
17
|
-
export declare function fetchSearchTweets(query: string, maxTweets: number, searchMode: SearchMode, auth: TwitterAuth, cursor?: string): Promise<QueryTweetsResponse>;
|
|
18
|
-
export declare function fetchSearchProfiles(query: string, maxProfiles: number, auth: TwitterAuth, cursor?: string): Promise<QueryProfilesResponse>;
|
|
19
|
-
//# sourceMappingURL=search.d.ts.map
|
package/dist/search.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAQjC;;GAEG;AACH,oBAAY,UAAU;IACpB,GAAG,IAAA;IACH,MAAM,IAAA;IACN,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;CACN;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,WAAW,GAChB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAI7B;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,WAAW,GAChB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAI/B;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC,CAUhC"}
|
package/dist/search.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchSearchProfiles = exports.fetchSearchTweets = exports.searchProfiles = exports.searchTweets = exports.SearchMode = void 0;
|
|
7
|
-
const api_1 = require("./api");
|
|
8
|
-
const timeline_async_1 = require("./timeline-async");
|
|
9
|
-
const timeline_search_1 = require("./timeline-search");
|
|
10
|
-
const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
|
|
11
|
-
/**
|
|
12
|
-
* The categories that can be used in Twitter searches.
|
|
13
|
-
*/
|
|
14
|
-
var SearchMode;
|
|
15
|
-
(function (SearchMode) {
|
|
16
|
-
SearchMode[SearchMode["Top"] = 0] = "Top";
|
|
17
|
-
SearchMode[SearchMode["Latest"] = 1] = "Latest";
|
|
18
|
-
SearchMode[SearchMode["Photos"] = 2] = "Photos";
|
|
19
|
-
SearchMode[SearchMode["Videos"] = 3] = "Videos";
|
|
20
|
-
SearchMode[SearchMode["Users"] = 4] = "Users";
|
|
21
|
-
})(SearchMode || (exports.SearchMode = SearchMode = {}));
|
|
22
|
-
function searchTweets(query, maxTweets, searchMode, auth) {
|
|
23
|
-
return (0, timeline_async_1.getTweetTimeline)(query, maxTweets, (q, mt, c) => {
|
|
24
|
-
return fetchSearchTweets(q, mt, searchMode, auth, c);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.searchTweets = searchTweets;
|
|
28
|
-
function searchProfiles(query, maxProfiles, auth) {
|
|
29
|
-
return (0, timeline_async_1.getUserTimeline)(query, maxProfiles, (q, mt, c) => {
|
|
30
|
-
return fetchSearchProfiles(q, mt, auth, c);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.searchProfiles = searchProfiles;
|
|
34
|
-
async function fetchSearchTweets(query, maxTweets, searchMode, auth, cursor) {
|
|
35
|
-
const timeline = await getSearchTimeline(query, maxTweets, searchMode, auth, cursor);
|
|
36
|
-
return (0, timeline_search_1.parseSearchTimelineTweets)(timeline);
|
|
37
|
-
}
|
|
38
|
-
exports.fetchSearchTweets = fetchSearchTweets;
|
|
39
|
-
async function fetchSearchProfiles(query, maxProfiles, auth, cursor) {
|
|
40
|
-
const timeline = await getSearchTimeline(query, maxProfiles, SearchMode.Users, auth, cursor);
|
|
41
|
-
return (0, timeline_search_1.parseSearchTimelineUsers)(timeline);
|
|
42
|
-
}
|
|
43
|
-
exports.fetchSearchProfiles = fetchSearchProfiles;
|
|
44
|
-
async function getSearchTimeline(query, maxItems, searchMode, auth, cursor) {
|
|
45
|
-
if (!auth.isLoggedIn()) {
|
|
46
|
-
throw new Error('Scraper is not logged-in for search.');
|
|
47
|
-
}
|
|
48
|
-
if (maxItems > 50) {
|
|
49
|
-
maxItems = 50;
|
|
50
|
-
}
|
|
51
|
-
const variables = {
|
|
52
|
-
rawQuery: query,
|
|
53
|
-
count: maxItems,
|
|
54
|
-
querySource: 'typed_query',
|
|
55
|
-
product: 'Top',
|
|
56
|
-
};
|
|
57
|
-
const features = (0, api_1.addApiFeatures)({
|
|
58
|
-
longform_notetweets_inline_media_enabled: true,
|
|
59
|
-
responsive_web_enhance_cards_enabled: false,
|
|
60
|
-
responsive_web_media_download_video_enabled: false,
|
|
61
|
-
responsive_web_twitter_article_tweet_consumption_enabled: false,
|
|
62
|
-
tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled: true,
|
|
63
|
-
interactive_text_enabled: false,
|
|
64
|
-
responsive_web_text_conversations_enabled: false,
|
|
65
|
-
vibe_api_enabled: false,
|
|
66
|
-
});
|
|
67
|
-
const fieldToggles = {
|
|
68
|
-
withArticleRichContentState: false,
|
|
69
|
-
};
|
|
70
|
-
if (cursor != null && cursor != '') {
|
|
71
|
-
variables['cursor'] = cursor;
|
|
72
|
-
}
|
|
73
|
-
switch (searchMode) {
|
|
74
|
-
case SearchMode.Latest:
|
|
75
|
-
variables.product = 'Latest';
|
|
76
|
-
break;
|
|
77
|
-
case SearchMode.Photos:
|
|
78
|
-
variables.product = 'Photos';
|
|
79
|
-
break;
|
|
80
|
-
case SearchMode.Videos:
|
|
81
|
-
variables.product = 'Videos';
|
|
82
|
-
break;
|
|
83
|
-
case SearchMode.Users:
|
|
84
|
-
variables.product = 'People';
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
const params = new URLSearchParams();
|
|
90
|
-
params.set('features', (0, json_stable_stringify_1.default)(features));
|
|
91
|
-
params.set('fieldToggles', (0, json_stable_stringify_1.default)(fieldToggles));
|
|
92
|
-
params.set('variables', (0, json_stable_stringify_1.default)(variables));
|
|
93
|
-
const res = await (0, api_1.requestApi)(`https://api.twitter.com/graphql/gkjsKepM6gl_HmFWoWKfgg/SearchTimeline?${params.toString()}`, auth);
|
|
94
|
-
if (!res.success) {
|
|
95
|
-
throw res.err;
|
|
96
|
-
}
|
|
97
|
-
return res.value;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=search.js.map
|
package/dist/search.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAmD;AAInD,qDAAqE;AAErE,uDAI2B;AAC3B,kFAA8C;AAE9C;;GAEG;AACH,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yCAAG,CAAA;IACH,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,6CAAK,CAAA;AACP,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAED,SAAgB,YAAY,CAC1B,KAAa,EACb,SAAiB,EACjB,UAAsB,EACtB,IAAiB;IAEjB,OAAO,IAAA,iCAAgB,EAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;QACrD,OAAO,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AATD,oCASC;AAED,SAAgB,cAAc,CAC5B,KAAa,EACb,WAAmB,EACnB,IAAiB;IAEjB,OAAO,IAAA,gCAAe,EAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;QACtD,OAAO,mBAAmB,CAAC,CAAC,EAA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DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Profile } from './profile';
|
|
2
|
-
import { Tweet } from './tweets';
|
|
3
|
-
export interface FetchProfilesResponse {
|
|
4
|
-
profiles: Profile[];
|
|
5
|
-
next?: string;
|
|
6
|
-
}
|
|
7
|
-
export type FetchProfiles = (query: string, maxProfiles: number, cursor: string | undefined) => Promise<FetchProfilesResponse>;
|
|
8
|
-
export interface FetchTweetsResponse {
|
|
9
|
-
tweets: Tweet[];
|
|
10
|
-
next?: string;
|
|
11
|
-
}
|
|
12
|
-
export type FetchTweets = (query: string, maxTweets: number, cursor: string | undefined) => Promise<FetchTweetsResponse>;
|
|
13
|
-
export declare function getUserTimeline(query: string, maxProfiles: number, fetchFunc: FetchProfiles): AsyncGenerator<Profile, void>;
|
|
14
|
-
export declare function getTweetTimeline(query: string, maxTweets: number, fetchFunc: FetchTweets): AsyncGenerator<Tweet, void>;
|
|
15
|
-
//# sourceMappingURL=timeline-async.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-async.d.ts","sourceRoot":"","sources":["../src/timeline-async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GAAG,SAAS,KACvB,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEpC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GAAG,SAAS,KACvB,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAElC,wBAAuB,eAAe,CACpC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,aAAa,GACvB,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CA2B/B;AAED,wBAAuB,gBAAgB,CACrC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,WAAW,GACrB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CA2B7B"}
|
package/dist/timeline-async.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTweetTimeline = exports.getUserTimeline = void 0;
|
|
4
|
-
async function* getUserTimeline(query, maxProfiles, fetchFunc) {
|
|
5
|
-
let nProfiles = 0;
|
|
6
|
-
let cursor = undefined;
|
|
7
|
-
let consecutiveEmptyBatches = 0;
|
|
8
|
-
while (nProfiles < maxProfiles) {
|
|
9
|
-
const batch = await fetchFunc(query, maxProfiles, cursor);
|
|
10
|
-
const { profiles, next } = batch;
|
|
11
|
-
cursor = next;
|
|
12
|
-
if (profiles.length === 0) {
|
|
13
|
-
consecutiveEmptyBatches++;
|
|
14
|
-
if (consecutiveEmptyBatches > 5)
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
consecutiveEmptyBatches = 0;
|
|
19
|
-
for (const profile of profiles) {
|
|
20
|
-
if (nProfiles < maxProfiles)
|
|
21
|
-
yield profile;
|
|
22
|
-
else
|
|
23
|
-
break;
|
|
24
|
-
nProfiles++;
|
|
25
|
-
}
|
|
26
|
-
if (!next)
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.getUserTimeline = getUserTimeline;
|
|
31
|
-
async function* getTweetTimeline(query, maxTweets, fetchFunc) {
|
|
32
|
-
let nTweets = 0;
|
|
33
|
-
let cursor = undefined;
|
|
34
|
-
while (nTweets < maxTweets) {
|
|
35
|
-
const batch = await fetchFunc(query, maxTweets, cursor);
|
|
36
|
-
const { tweets, next } = batch;
|
|
37
|
-
if (tweets.length === 0) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
for (const tweet of tweets) {
|
|
41
|
-
if (nTweets < maxTweets) {
|
|
42
|
-
cursor = next;
|
|
43
|
-
yield tweet;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
nTweets++;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.getTweetTimeline = getTweetTimeline;
|
|
53
|
-
//# sourceMappingURL=timeline-async.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-async.js","sourceRoot":"","sources":["../src/timeline-async.ts"],"names":[],"mappings":";;;AAyBO,KAAK,SAAS,CAAC,CAAC,eAAe,CACpC,KAAa,EACb,WAAmB,EACnB,SAAwB;IAExB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,uBAAuB,GAAG,CAAC,CAAC;IAChC,OAAO,SAAS,GAAG,WAAW,EAAE;QAC9B,MAAM,KAAK,GAA0B,MAAM,SAAS,CAClD,KAAK,EACL,WAAW,EACX,MAAM,CACP,CAAC;QAEF,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACjC,MAAM,GAAG,IAAI,CAAC;QAEd,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,uBAAuB,EAAE,CAAC;YAC1B,IAAI,uBAAuB,GAAG,CAAC;gBAAE,MAAM;SACxC;;YAAM,uBAAuB,GAAG,CAAC,CAAC;QAEnC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,IAAI,SAAS,GAAG,WAAW;gBAAE,MAAM,OAAO,CAAC;;gBACtC,MAAM;YACX,SAAS,EAAE,CAAC;SACb;QAED,IAAI,CAAC,IAAI;YAAE,MAAM;KAClB;AACH,CAAC;AA/BD,0CA+BC;AAEM,KAAK,SAAS,CAAC,CAAC,gBAAgB,CACrC,KAAa,EACb,SAAiB,EACjB,SAAsB;IAEtB,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,OAAO,OAAO,GAAG,SAAS,EAAE;QAC1B,MAAM,KAAK,GAAwB,MAAM,SAAS,CAChD,KAAK,EACL,SAAS,EACT,MAAM,CACP,CAAC;QAEF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAE/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM;SACP;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,OAAO,GAAG,SAAS,EAAE;gBACvB,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM,KAAK,CAAC;aACb;iBAAM;gBACL,MAAM;aACP;YAED,OAAO,EAAE,CAAC;SACX;KACF;AACH,CAAC;AA/BD,4CA+BC"}
|
package/dist/timeline-list.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { QueryTweetsResponse } from './timeline-v1';
|
|
2
|
-
import { TimelineEntryRaw } from './timeline-v2';
|
|
3
|
-
export interface ListTimeline {
|
|
4
|
-
data?: {
|
|
5
|
-
list?: {
|
|
6
|
-
tweets_timeline?: {
|
|
7
|
-
timeline?: {
|
|
8
|
-
instructions?: {
|
|
9
|
-
entries?: TimelineEntryRaw[];
|
|
10
|
-
entry?: TimelineEntryRaw;
|
|
11
|
-
type?: string;
|
|
12
|
-
}[];
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare function parseListTimelineTweets(timeline: ListTimeline): QueryTweetsResponse;
|
|
19
|
-
//# sourceMappingURL=timeline-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-list.d.ts","sourceRoot":"","sources":["../src/timeline-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAgB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG/D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE;YACL,eAAe,CAAC,EAAE;gBAChB,QAAQ,CAAC,EAAE;oBACT,YAAY,CAAC,EAAE;wBACb,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;wBAC7B,KAAK,CAAC,EAAE,gBAAgB,CAAC;wBACzB,IAAI,CAAC,EAAE,MAAM,CAAC;qBACf,EAAE,CAAC;iBACL,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,YAAY,GACrB,mBAAmB,CAkDrB"}
|