@wargas/crawler 0.0.1
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 +15 -0
- package/bun.lock +89 -0
- package/dist/index.js +13088 -0
- package/index.ts +25 -0
- package/package.json +22 -0
- package/tsconfig.json +31 -0
package/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Got } from "got";
|
|
2
|
+
import got from "got";
|
|
3
|
+
import { CookieJar } from "tough-cookie";
|
|
4
|
+
import FileCookieStore from "tough-cookie-file-store";
|
|
5
|
+
|
|
6
|
+
export class Crawler {
|
|
7
|
+
client!: Got
|
|
8
|
+
cookieJar!: CookieJar
|
|
9
|
+
|
|
10
|
+
static factory() {
|
|
11
|
+
const instance = new Crawler()
|
|
12
|
+
|
|
13
|
+
instance.cookieJar = new CookieJar(new FileCookieStore(`cookies.json`))
|
|
14
|
+
|
|
15
|
+
instance.client = got.extend({
|
|
16
|
+
cookieJar: instance.cookieJar
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async removeAllCookies(){
|
|
23
|
+
await this.cookieJar.removeAllCookies()
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wargas/crawler",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"module": "index.ts",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "bun build index.ts --target node --outdir dist"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bun": "latest"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"typescript": "^5"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"got": "^15.0.5",
|
|
19
|
+
"tough-cookie": "^6.0.1",
|
|
20
|
+
"tough-cookie-file-store": "^3.3.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment setup & latest features
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"types": ["bun"],
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
|
|
13
|
+
// Bundler mode
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"allowImportingTsExtensions": true,
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"noEmit": true,
|
|
18
|
+
|
|
19
|
+
// Best practices
|
|
20
|
+
"strict": true,
|
|
21
|
+
"skipLibCheck": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedIndexedAccess": true,
|
|
24
|
+
"noImplicitOverride": true,
|
|
25
|
+
|
|
26
|
+
// Some stricter flags (disabled by default)
|
|
27
|
+
"noUnusedLocals": false,
|
|
28
|
+
"noUnusedParameters": false,
|
|
29
|
+
"noPropertyAccessFromIndexSignature": false
|
|
30
|
+
}
|
|
31
|
+
}
|