@the-convocation/twitter-scraper 0.19.0 → 0.20.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 +3 -3
- package/dist/default/cjs/index.js +419 -177
- package/dist/default/cjs/index.js.map +1 -1
- package/dist/default/esm/index.mjs +419 -177
- package/dist/default/esm/index.mjs.map +1 -1
- package/dist/node/cjs/index.cjs +416 -174
- package/dist/node/cjs/index.cjs.map +1 -1
- package/dist/node/esm/index.mjs +416 -174
- package/dist/node/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +13 -0
- package/examples/cycletls/README.md +4 -10
- package/examples/cycletls/package.json +1 -0
- package/examples/node-integration/package.json +2 -1
- package/package.json +6 -4
package/dist/types/index.d.ts
CHANGED
|
@@ -701,6 +701,19 @@ interface ScraperOptions {
|
|
|
701
701
|
* A handling strategy for rate limits (HTTP 429).
|
|
702
702
|
*/
|
|
703
703
|
rateLimitStrategy: RateLimitStrategy;
|
|
704
|
+
/**
|
|
705
|
+
* Experimental features that may be added, changed, or removed at any time. Use with caution.
|
|
706
|
+
*/
|
|
707
|
+
experimental: {
|
|
708
|
+
/**
|
|
709
|
+
* Enables the generation of the `x-client-transaction-id` header on requests. This may resolve some errors.
|
|
710
|
+
*/
|
|
711
|
+
xClientTransactionId: boolean;
|
|
712
|
+
/**
|
|
713
|
+
* Enables the generation of the `x-xp-forwarded-for` header on requests. This may resolve some errors.
|
|
714
|
+
*/
|
|
715
|
+
xpff: boolean;
|
|
716
|
+
};
|
|
704
717
|
}
|
|
705
718
|
/**
|
|
706
719
|
* An interface to Twitter's undocumented API.
|
|
@@ -4,11 +4,11 @@ This example demonstrates how to use the `@the-convocation/twitter-scraper/cycle
|
|
|
4
4
|
|
|
5
5
|
## Problem
|
|
6
6
|
|
|
7
|
-
Twitter's authentication endpoints may be protected by Cloudflare's
|
|
7
|
+
Twitter's authentication endpoints may be protected by Cloudflare's bot detection, which analyzes TLS fingerprints to detect non-browser clients. Standard Node.js TLS handshakes can trigger `403 Forbidden` errors during login.
|
|
8
8
|
|
|
9
9
|
## Solution
|
|
10
10
|
|
|
11
|
-
This example uses [CycleTLS](https://github.com/Danny-Dasilva/CycleTLS)
|
|
11
|
+
This example uses [CycleTLS](https://github.com/Danny-Dasilva/CycleTLS) to mimic Chrome browser TLS fingerprints, allowing requests to pass through Cloudflare's protection.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ yarn install
|
|
|
18
18
|
|
|
19
19
|
## Configuration
|
|
20
20
|
|
|
21
|
-
Create a `.env` file in
|
|
21
|
+
Create a `.env` file in this directory with your Twitter credentials:
|
|
22
22
|
|
|
23
23
|
```
|
|
24
24
|
TWITTER_USERNAME=your_username
|
|
@@ -41,14 +41,8 @@ import { Scraper } from '@the-convocation/twitter-scraper';
|
|
|
41
41
|
import { cycleTLSFetch, cycleTLSExit } from '@the-convocation/twitter-scraper/cycletls';
|
|
42
42
|
|
|
43
43
|
const scraper = new Scraper({
|
|
44
|
-
fetch: cycleTLSFetch
|
|
44
|
+
fetch: cycleTLSFetch,
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
This replaces the default fetch implementation with one that uses Chrome-like TLS fingerprints, bypassing Cloudflare's detection.
|
|
49
|
-
|
|
50
|
-
## Important Notes
|
|
51
|
-
|
|
52
|
-
- **Node.js only**: The `/cycletls` entrypoint requires Node.js and will not work in browsers
|
|
53
|
-
- **Cleanup required**: Always call `cycleTLSExit()` when done to cleanup golang resources
|
|
54
|
-
- **Optional dependency**: `cycletls` must be explicitly installed alongside the main package
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scraper",
|
|
8
8
|
"crawler"
|
|
9
9
|
],
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.20.0",
|
|
11
11
|
"main": "dist/default/cjs/index.js",
|
|
12
12
|
"types": "./dist/types/index.d.ts",
|
|
13
13
|
"exports": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"docs:deploy": "yarn docs:generate && gh-pages -d docs",
|
|
43
43
|
"format": "prettier --write src/**/*.ts examples/**/*.{ts,js,tsx}",
|
|
44
44
|
"prepare": "husky install",
|
|
45
|
-
"test": "jest"
|
|
45
|
+
"test": "jest --runInBand --forceExit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@sinclair/typebox": "^0.32.20",
|
|
@@ -50,13 +50,15 @@
|
|
|
50
50
|
"debug": "^4.4.1",
|
|
51
51
|
"headers-polyfill": "^3.1.2",
|
|
52
52
|
"json-stable-stringify": "^1.0.2",
|
|
53
|
+
"linkedom": "^0.18.12",
|
|
53
54
|
"otpauth": "^9.2.2",
|
|
54
55
|
"set-cookie-parser": "^2.6.0",
|
|
55
56
|
"tough-cookie": "^4.1.2",
|
|
56
|
-
"tslib": "^2.5.2"
|
|
57
|
+
"tslib": "^2.5.2",
|
|
58
|
+
"x-client-transaction-id": "^0.1.9"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
|
-
"cycletls": "^2.0.
|
|
61
|
+
"cycletls": "^2.0.5"
|
|
60
62
|
},
|
|
61
63
|
"peerDependenciesMeta": {
|
|
62
64
|
"cycletls": {
|