@the-convocation/twitter-scraper
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -88,2 +88,32 @@ import { Cookie } from 'tough-cookie'; | ||
/** | ||
* Fetch the profiles a user is following | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @returns An {@link AsyncGenerator} of following profiles for the provided user. | ||
*/ | ||
getFollowing(userId: string, maxProfiles: number): AsyncGenerator<Profile, void>; | ||
/** | ||
* Fetch the profiles that follow a user | ||
* @param userId The user whose followers should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @returns An {@link AsyncGenerator} of profiles following the provided user. | ||
*/ | ||
getFollowers(userId: string, maxProfiles: number): AsyncGenerator<Profile, void>; | ||
/** | ||
* Fetches following profiles from Twitter. | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @param cursor The search cursor, which can be passed into further requests for more results. | ||
* @returns A page of results, containing a cursor that can be used in further requests. | ||
*/ | ||
fetchProfileFollowing(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>; | ||
/** | ||
* Fetches profile followers from Twitter. | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @param cursor The search cursor, which can be passed into further requests for more results. | ||
* @returns A page of results, containing a cursor that can be used in further requests. | ||
*/ | ||
fetchProfileFollowers(userId: string, maxProfiles: number, cursor?: string): Promise<QueryProfilesResponse>; | ||
/** | ||
* Fetches the current trends from Twitter. | ||
@@ -90,0 +120,0 @@ * @returns The current list of trends. |
@@ -9,2 +9,3 @@ "use strict"; | ||
const search_1 = require("./search"); | ||
const relationships_1 = require("./relationships"); | ||
const trends_1 = require("./trends"); | ||
@@ -98,2 +99,40 @@ const tweets_1 = require("./tweets"); | ||
/** | ||
* Fetch the profiles a user is following | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @returns An {@link AsyncGenerator} of following profiles for the provided user. | ||
*/ | ||
getFollowing(userId, maxProfiles) { | ||
return (0, relationships_1.getFollowing)(userId, maxProfiles, this.auth); | ||
} | ||
/** | ||
* Fetch the profiles that follow a user | ||
* @param userId The user whose followers should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @returns An {@link AsyncGenerator} of profiles following the provided user. | ||
*/ | ||
getFollowers(userId, maxProfiles) { | ||
return (0, relationships_1.getFollowers)(userId, maxProfiles, this.auth); | ||
} | ||
/** | ||
* Fetches following profiles from Twitter. | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @param cursor The search cursor, which can be passed into further requests for more results. | ||
* @returns A page of results, containing a cursor that can be used in further requests. | ||
*/ | ||
fetchProfileFollowing(userId, maxProfiles, cursor) { | ||
return (0, relationships_1.fetchProfileFollowing)(userId, maxProfiles, this.auth, cursor); | ||
} | ||
/** | ||
* Fetches profile followers from Twitter. | ||
* @param userId The user whose following should be returned | ||
* @param maxProfiles The maximum number of profiles to return. | ||
* @param cursor The search cursor, which can be passed into further requests for more results. | ||
* @returns A page of results, containing a cursor that can be used in further requests. | ||
*/ | ||
fetchProfileFollowers(userId, maxProfiles, cursor) { | ||
return (0, relationships_1.fetchProfileFollowers)(userId, maxProfiles, this.auth, cursor); | ||
} | ||
/** | ||
* Fetches the current trends from Twitter. | ||
@@ -100,0 +139,0 @@ * @returns The current list of trends. |
@@ -21,3 +21,3 @@ "use strict"; | ||
SearchMode[SearchMode["Users"] = 4] = "Users"; | ||
})(SearchMode = exports.SearchMode || (exports.SearchMode = {})); | ||
})(SearchMode || (exports.SearchMode = SearchMode = {})); | ||
function searchTweets(query, maxTweets, searchMode, auth) { | ||
@@ -24,0 +24,0 @@ return (0, timeline_async_1.getTweetTimeline)(query, maxTweets, (q, mt, c) => { |
{ | ||
"name": "@the-convocation/twitter-scraper", | ||
"version": "0.7.0", | ||
"description": "A port of n0madic/twitter-scraper to Node.js.", | ||
"keywords": ["x", "twitter", "scraper"], | ||
"version": "0.8.0", | ||
"main": "dist/_module.js", | ||
@@ -11,2 +13,3 @@ "repository": "https://github.com/the-convocation/twitter-scraper.git", | ||
}, | ||
"packageManager": "yarn@1.22.19", | ||
"scripts": { | ||
@@ -45,2 +48,3 @@ "build": "tsc", | ||
"gh-pages": "^5.0.0", | ||
"https-proxy-agent": "^7.0.2", | ||
"husky": "^8.0.3", | ||
@@ -47,0 +51,0 @@ "jest": "^29.5.0", |
@@ -152,2 +152,35 @@ # twitter-scraper | ||
## Contributing | ||
We use [Conventional Commits](https://www.conventionalcommits.org), and enforce this with precommit checks. | ||
### Setup | ||
This project currently targets Node 16.x and uses Yarn for package management. [Corepack](https://nodejs.org/dist/latest-v16.x/docs/api/corepack.html) | ||
is configured for this project, so you don't need to install a particular package manager version manually. | ||
Just run `corepack enable` to turn on the shims, then run `yarn` to install the dependencies. | ||
#### Basic scripts | ||
* `yarn build`: Builds the project into the `dist` folder | ||
* `yarn test`: Runs the package tests (see [Testing](#testing) first) | ||
Run `yarn help` for general `yarn` usage information. | ||
### Testing | ||
This package includes unit tests for all major functionality. Given the speed at which Twitter's private API | ||
changes, failing tests are to be expected. | ||
```sh | ||
yarn test | ||
``` | ||
Before running tests, you should configure environment variables for authentication. | ||
``` | ||
TWITTER_USERNAME= # Account username | ||
TWITTER_PASSWORD= # Account password | ||
TWITTER_EMAIL= # Account email | ||
TWITTER_COOKIES= # JSON-serialized array of cookies of an authenticated session | ||
PROXY_URL= # HTTP(s) proxy for requests (optional) | ||
``` | ||
### Commit message format | ||
We use [Conventional Commits](https://www.conventionalcommits.org), and enforce this with precommit checks. | ||
Please refer to the Git history for real examples of the commit message format. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
217743
79
3138
186
23