@things-factory/integration-headless 8.0.0 → 9.0.0-beta.3
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-server/engine/index.d.ts +0 -1
- package/dist-server/engine/index.js +0 -1
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/pdf-capture-util.d.ts +1 -1
- package/dist-server/engine/task/pdf-capture-util.js +3 -3
- package/dist-server/engine/task/pdf-capture-util.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/connector/headless-connector.ja.md +183 -31
- package/helps/integration/connector/headless-connector.ko.md +177 -32
- package/helps/integration/connector/headless-connector.md +178 -31
- package/helps/integration/connector/headless-connector.ms.md +180 -32
- package/helps/integration/connector/headless-connector.zh.md +178 -31
- package/package.json +6 -6
- package/dist-server/engine/connector/headless-connector.d.ts +0 -14
- package/dist-server/engine/connector/headless-connector.js +0 -54
- package/dist-server/engine/connector/headless-connector.js.map +0 -1
- package/dist-server/engine/connector/headless-pool.d.ts +0 -3
- package/dist-server/engine/connector/headless-pool.js +0 -63
- package/dist-server/engine/connector/headless-pool.js.map +0 -1
- package/dist-server/engine/connector/index.d.ts +0 -1
- package/dist-server/engine/connector/index.js +0 -4
- package/dist-server/engine/connector/index.js.map +0 -1
- package/server/engine/connector/headless-connector.ts +0 -68
- package/server/engine/connector/headless-pool.ts +0 -69
- package/server/engine/connector/index.ts +0 -1
- package/server/engine/index.ts +0 -2
- package/server/engine/task/headless-pdf-capture-board.ts +0 -182
- package/server/engine/task/headless-pdf-capture-markdown.ts +0 -47
- package/server/engine/task/headless-pdf-capture.ts +0 -39
- package/server/engine/task/headless-pdf-open.ts +0 -98
- package/server/engine/task/headless-pdf-save.ts +0 -88
- package/server/engine/task/index.ts +0 -9
- package/server/engine/task/pdf-capture-util.ts +0 -331
- package/server/index.ts +0 -3
- package/server/tsconfig.json +0 -10
|
@@ -1,57 +1,168 @@
|
|
|
1
|
-
### Headless
|
|
1
|
+
### 🏆 Headless Connector
|
|
2
2
|
|
|
3
|
-
**Headless
|
|
3
|
+
The **Headless Connector** is a powerful tool that utilizes headless browsers to perform **automated login**, **web scraping**, **PDF generation**, and **form submission** tasks.
|
|
4
|
+
It manages multiple browser sessions, maintains sessions, handles cookies, and supports API-based logins.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
---
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## 🚀 1. Endpoint
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
The endpoint for the **Headless Connector** should be the **URL of the target website** that you want to scrape or interact with.
|
|
11
|
+
For example, you can input `https://example.com` to extract content from that website. If you need to generate a PDF from internal content, you can also use `localhost`.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- Specifies the minimum number of headless browser instances to maintain in the pool.
|
|
13
|
-
- Default value: `2`
|
|
14
|
-
- **max** (number):
|
|
15
|
-
- Specifies the maximum number of headless browser instances the pool can handle.
|
|
16
|
-
- Default value: `10`
|
|
13
|
+
---
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
## 🔧 2. Parameters
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
### ✅ Login Configuration
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description | Default Value |
|
|
20
|
+
| -------------------- | -------- | ------------------------------------------------- | ------------- |
|
|
21
|
+
| `username` | `string` | Username (login ID) | `""` |
|
|
22
|
+
| `password` | `string` | Password for login | `""` |
|
|
23
|
+
| `loginPagePath` | `string` | Path to the login page (e.g., `/login`) | `"/login"` |
|
|
24
|
+
| `loginApiUrl` | `string` | API endpoint for login (if applicable) | `null` |
|
|
25
|
+
| `usernameSelector` | `string` | CSS selector for the username input field | `"#username"` |
|
|
26
|
+
| `passwordSelector` | `string` | CSS selector for the password input field | `"#password"` |
|
|
27
|
+
| `submitSelector` | `string` | CSS selector for the login button | `"#submit"` |
|
|
28
|
+
| `successSelector` | `string` | CSS selector to verify login success | `null` |
|
|
29
|
+
| `shadowDomSelectors` | `string` | Comma-separated selectors for shadow DOM elements | `""` |
|
|
30
|
+
| `timeout` | `number` | Timeout for login and page loading (ms) | `15000` |
|
|
31
|
+
| `retries` | `number` | Number of login retries | `3` |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔍 3. Detailed Explanation of `loginApiUrl`
|
|
36
|
+
|
|
37
|
+
### 🔹 What is `loginApiUrl`?
|
|
38
|
+
|
|
39
|
+
`loginApiUrl` is used when the website employs **API-based login** instead of traditional HTML form-based login. This parameter helps the connector determine how to handle the login process.
|
|
40
|
+
|
|
41
|
+
### ✅ If `loginApiUrl` is **NOT set (`null`)**
|
|
42
|
+
|
|
43
|
+
The **HTML form submission method** is used to log in.
|
|
44
|
+
The headless browser will manually enter the username and password into the login form and click the submit button.
|
|
45
|
+
|
|
46
|
+
#### 📌 Example (HTML Form-Based Login)
|
|
21
47
|
|
|
22
48
|
```json
|
|
23
49
|
{
|
|
24
|
-
"
|
|
50
|
+
"endpoint": "https://example.com",
|
|
51
|
+
"params": {
|
|
52
|
+
"username": "user123",
|
|
53
|
+
"password": "securepassword",
|
|
54
|
+
"loginPagePath": "/login",
|
|
55
|
+
"usernameSelector": "#username",
|
|
56
|
+
"passwordSelector": "#password",
|
|
57
|
+
"submitSelector": "#submit-button",
|
|
58
|
+
"successSelector": ".dashboard"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### 🛠 How it Works:
|
|
64
|
+
|
|
65
|
+
1. Navigate to `https://example.com/login`
|
|
66
|
+
2. Enter credentials into `#username` and `#password`
|
|
67
|
+
3. Click `#submit-button` to submit the form
|
|
68
|
+
4. Check if `.dashboard` exists to determine if login was successful
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### ✅ If `loginApiUrl` **IS set**
|
|
73
|
+
|
|
74
|
+
If the website uses **API-based authentication**, `loginApiUrl` should be explicitly set to the login API's endpoint.
|
|
75
|
+
For example, if the login API is `/api/auth/login`, this value must be configured accordingly.
|
|
76
|
+
|
|
77
|
+
#### 📌 Example (API-Based Login)
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"endpoint": "https://example.com",
|
|
82
|
+
"params": {
|
|
83
|
+
"username": "user123",
|
|
84
|
+
"password": "securepassword",
|
|
85
|
+
"loginPagePath": "/login",
|
|
86
|
+
"loginApiUrl": "/api/auth/login",
|
|
87
|
+
"usernameSelector": "#username",
|
|
88
|
+
"passwordSelector": "#password",
|
|
89
|
+
"submitSelector": "#submit-button",
|
|
90
|
+
"successSelector": ".dashboard"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 🛠 How it Works:
|
|
96
|
+
|
|
97
|
+
1. Sends a **POST request** to `https://example.com/api/auth/login`
|
|
98
|
+
2. Receives a response from the server and stores the session cookies
|
|
99
|
+
3. Navigates to the main page and checks for `.dashboard` to verify login success
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 🏗 4. Example Configuration
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"name": "headless-browser-connector",
|
|
25
108
|
"connector": "headless-connector",
|
|
26
|
-
"endpoint": "
|
|
109
|
+
"endpoint": "https://example.com",
|
|
27
110
|
"params": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
111
|
+
"username": "user123",
|
|
112
|
+
"password": "securepassword",
|
|
113
|
+
"loginPagePath": "/login",
|
|
114
|
+
"loginApiUrl": "/api/auth/login",
|
|
115
|
+
"usernameSelector": "#username",
|
|
116
|
+
"passwordSelector": "#password",
|
|
117
|
+
"submitSelector": "#submit",
|
|
118
|
+
"successSelector": ".dashboard",
|
|
119
|
+
"timeout": 20000,
|
|
120
|
+
"retries": 5
|
|
30
121
|
}
|
|
31
122
|
}
|
|
32
123
|
```
|
|
33
124
|
|
|
34
|
-
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 🔄 5. Connection Lifecycle
|
|
128
|
+
|
|
129
|
+
- **connect**
|
|
35
130
|
|
|
36
|
-
|
|
131
|
+
- Performs the login process according to the provided parameters.
|
|
132
|
+
- Maintains the session and stores cookies for future requests.
|
|
37
133
|
|
|
38
|
-
- **
|
|
134
|
+
- **disconnect**
|
|
135
|
+
- Terminates the browser session and clears cookies.
|
|
39
136
|
|
|
40
|
-
|
|
41
|
-
- The pool automatically manages the lifecycle of these instances, creating new ones as needed and reusing existing ones.
|
|
137
|
+
---
|
|
42
138
|
|
|
43
|
-
|
|
44
|
-
- Destroys the headless browser pool, ensuring all instances are properly terminated and resources are released.
|
|
139
|
+
## ⚡ 6. Supported Tasks
|
|
45
140
|
|
|
46
|
-
|
|
141
|
+
| Task Type | Description |
|
|
142
|
+
| ---------------------- | -------------------------------------- |
|
|
143
|
+
| `headless-pdf-capture` | Converts HTML to a PDF |
|
|
144
|
+
| `headless-scrap` | Extracts specific data from a web page |
|
|
145
|
+
| `headless-post` | Automates form filling and submission |
|
|
47
146
|
|
|
48
|
-
|
|
147
|
+
#### 📌 Task Examples
|
|
49
148
|
|
|
50
|
-
|
|
149
|
+
### 1️⃣ Web Scraping (`headless-scrap`)
|
|
51
150
|
|
|
52
|
-
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"name": "scrape-data",
|
|
154
|
+
"taskType": "headless-scrap",
|
|
155
|
+
"params": {
|
|
156
|
+
"path": "/products",
|
|
157
|
+
"selectors": [
|
|
158
|
+
{ "text": "Product Name", "value": ".product-title" },
|
|
159
|
+
{ "text": "Price", "value": ".product-price" }
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
53
164
|
|
|
54
|
-
|
|
165
|
+
### 2️⃣ PDF Generation (`headless-pdf-capture`)
|
|
55
166
|
|
|
56
167
|
```json
|
|
57
168
|
{
|
|
@@ -66,6 +177,42 @@ In the example above, the pool maintains at least 5 headless browser instances a
|
|
|
66
177
|
}
|
|
67
178
|
```
|
|
68
179
|
|
|
69
|
-
|
|
180
|
+
### 3️⃣ Form Submission (`headless-post`)
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"name": "submit-form",
|
|
185
|
+
"taskType": "headless-post",
|
|
186
|
+
"params": {
|
|
187
|
+
"formPath": "/contact",
|
|
188
|
+
"fields": {
|
|
189
|
+
"#name": "John Doe",
|
|
190
|
+
"#email": "john@example.com",
|
|
191
|
+
"#message": "Hello, this is a test message!"
|
|
192
|
+
},
|
|
193
|
+
"submitSelector": "#submit-button"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 📢 7. Description
|
|
201
|
+
|
|
202
|
+
The **Headless Connector** is a powerful tool for **automated web scraping, PDF generation, and form submission** tasks.
|
|
203
|
+
It supports both **HTML-based logins** and **API-based logins**, making it suitable for a variety of website authentication methods.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
### 📌 Summary
|
|
208
|
+
|
|
209
|
+
| Feature | Description |
|
|
210
|
+
| ---------------------- | ----------------------------------------- |
|
|
211
|
+
| **HTML Form Login** | Simulates user interaction for login |
|
|
212
|
+
| **API Login** | Sends login requests via API (faster) |
|
|
213
|
+
| **Session Management** | Stores cookies for session persistence |
|
|
214
|
+
| **Web Scraping** | Extracts specific content from websites |
|
|
215
|
+
| **PDF Generation** | Converts HTML pages to PDF |
|
|
216
|
+
| **Form Submission** | Fills out and submits forms automatically |
|
|
70
217
|
|
|
71
|
-
|
|
218
|
+
📌 **With the Headless Connector, you can easily automate various tasks across different websites!** 🚀
|
|
@@ -1,59 +1,171 @@
|
|
|
1
|
-
### Penyambung
|
|
1
|
+
### 🏆 **Penyambung Headless (Headless Connector)**
|
|
2
2
|
|
|
3
|
-
**Penyambung
|
|
3
|
+
**Penyambung Headless** ialah alat yang kuat yang menggunakan pelayar headless untuk melaksanakan **log masuk automatik**, **pengikisan web (web scraping)**, **penjanaan PDF**, dan **penghantaran borang**.
|
|
4
|
+
Ia menguruskan berbilang sesi pelayar, mengekalkan sesi, mengendalikan kuki, serta menyokong log masuk berdasarkan API.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
---
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## 🚀 **1. Titik Akhir (Endpoint)**
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Titik akhir untuk **Penyambung Headless** ialah **URL laman web sasaran** yang ingin dikikis (scraping) atau berinteraksi dengannya.
|
|
11
|
+
Sebagai contoh, `https://example.com` boleh digunakan untuk mengekstrak data daripada laman web, atau `localhost` boleh digunakan jika anda ingin menjana fail PDF dari kandungan dalaman.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- Menentukan bilangan minimum contoh pelayar tanpa kepala yang dikekalkan dalam kolam.
|
|
13
|
-
- Nilai lalai: `2`
|
|
14
|
-
- **max** (nombor):
|
|
15
|
-
- Menentukan bilangan maksimum contoh pelayar tanpa kepala yang boleh diuruskan oleh kolam.
|
|
16
|
-
- Nilai lalai: `10`
|
|
13
|
+
---
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
## 🔧 **2. Parameter (Parameters)**
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
### ✅ **Tetapan Berkaitan Log Masuk**
|
|
18
|
+
|
|
19
|
+
| Parameter | Jenis | Penerangan | Nilai Lalai |
|
|
20
|
+
| -------------------- | -------- | ------------------------------------------------------------ | ------------- |
|
|
21
|
+
| `username` | `string` | ID pengguna untuk log masuk | `""` |
|
|
22
|
+
| `password` | `string` | Kata laluan untuk log masuk | `""` |
|
|
23
|
+
| `loginPagePath` | `string` | Laluan ke halaman log masuk (contoh: `/login`) | `"/login"` |
|
|
24
|
+
| `loginApiUrl` | `string` | URL API untuk log masuk (jika diperlukan) | `null` |
|
|
25
|
+
| `usernameSelector` | `string` | Pemilih CSS untuk medan input nama pengguna | `"#username"` |
|
|
26
|
+
| `passwordSelector` | `string` | Pemilih CSS untuk medan input kata laluan | `"#password"` |
|
|
27
|
+
| `submitSelector` | `string` | Pemilih CSS untuk butang log masuk | `"#submit"` |
|
|
28
|
+
| `successSelector` | `string` | Pemilih CSS untuk elemen yang menunjukkan kejayaan log masuk | `null` |
|
|
29
|
+
| `shadowDomSelectors` | `string` | Pemilih untuk elemen dalam Shadow DOM (dipisahkan koma) | `""` |
|
|
30
|
+
| `timeout` | `number` | Had masa menunggu untuk log masuk dan pemuatan halaman (ms) | `15000` |
|
|
31
|
+
| `retries` | `number` | Bilangan percubaan untuk log masuk | `3` |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔍 **3. Penjelasan Terperinci Mengenai `loginApiUrl`**
|
|
36
|
+
|
|
37
|
+
### 🔹 **Apa itu `loginApiUrl`?**
|
|
38
|
+
|
|
39
|
+
`loginApiUrl` ialah parameter yang digunakan untuk **log masuk berdasarkan API**.
|
|
40
|
+
Sesetengah laman web tidak menggunakan borang HTML biasa untuk log masuk tetapi menggunakan API backend untuk mengesahkan pengguna.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### ✅ **Jika `loginApiUrl` Tidak Ditetapkan (`null`)**
|
|
45
|
+
|
|
46
|
+
Dalam kes ini, **borang HTML biasa** digunakan untuk log masuk.
|
|
47
|
+
Pelayar headless akan mengisi nama pengguna dan kata laluan secara automatik, kemudian menghantar borang tersebut.
|
|
48
|
+
|
|
49
|
+
#### 📌 **Contoh (Log Masuk Borang HTML)**
|
|
21
50
|
|
|
22
51
|
```json
|
|
23
52
|
{
|
|
24
|
-
"
|
|
53
|
+
"endpoint": "https://example.com",
|
|
54
|
+
"params": {
|
|
55
|
+
"username": "user123",
|
|
56
|
+
"password": "securepassword",
|
|
57
|
+
"loginPagePath": "/login",
|
|
58
|
+
"usernameSelector": "#username",
|
|
59
|
+
"passwordSelector": "#password",
|
|
60
|
+
"submitSelector": "#submit-button",
|
|
61
|
+
"successSelector": ".dashboard"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### 🛠 **Proses Operasi**:
|
|
67
|
+
|
|
68
|
+
1. Pergi ke `https://example.com/login`.
|
|
69
|
+
2. Isi medan `#username` dan `#password`.
|
|
70
|
+
3. Klik butang `#submit-button` untuk menghantar borang.
|
|
71
|
+
4. Jika `.dashboard` wujud, log masuk dianggap berjaya.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### ✅ **Jika `loginApiUrl` Ditentukan**
|
|
76
|
+
|
|
77
|
+
Dalam kes ini, laman web menggunakan **log masuk berdasarkan API**, jadi URL API perlu dinyatakan secara eksplisit.
|
|
78
|
+
Sebagai contoh, jika API log masuk ialah `/api/auth/login`, ia mesti dinyatakan dalam parameter.
|
|
79
|
+
|
|
80
|
+
#### 📌 **Contoh (Log Masuk Berdasarkan API)**
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"endpoint": "https://example.com",
|
|
85
|
+
"params": {
|
|
86
|
+
"username": "user123",
|
|
87
|
+
"password": "securepassword",
|
|
88
|
+
"loginPagePath": "/login",
|
|
89
|
+
"loginApiUrl": "/api/auth/login",
|
|
90
|
+
"usernameSelector": "#username",
|
|
91
|
+
"passwordSelector": "#password",
|
|
92
|
+
"submitSelector": "#submit-button",
|
|
93
|
+
"successSelector": ".dashboard"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### 🛠 **Proses Operasi**:
|
|
99
|
+
|
|
100
|
+
1. Hantar **permintaan POST** ke `https://example.com/api/auth/login`.
|
|
101
|
+
2. Simpan kuki sesi selepas menerima respons.
|
|
102
|
+
3. Navigasi ke halaman utama dan periksa `.dashboard` untuk memastikan log masuk berjaya.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🏗 **4. Contoh Konfigurasi**
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"name": "headless-browser-connector",
|
|
25
111
|
"connector": "headless-connector",
|
|
26
|
-
"endpoint": "
|
|
112
|
+
"endpoint": "https://example.com",
|
|
27
113
|
"params": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
114
|
+
"username": "user123",
|
|
115
|
+
"password": "securepassword",
|
|
116
|
+
"loginPagePath": "/login",
|
|
117
|
+
"loginApiUrl": "/api/auth/login",
|
|
118
|
+
"usernameSelector": "#username",
|
|
119
|
+
"passwordSelector": "#password",
|
|
120
|
+
"submitSelector": "#submit",
|
|
121
|
+
"successSelector": ".dashboard",
|
|
122
|
+
"timeout": 20000,
|
|
123
|
+
"retries": 5
|
|
30
124
|
}
|
|
31
125
|
}
|
|
32
126
|
```
|
|
33
127
|
|
|
34
|
-
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 🔄 **5. Kitaran Hayat Sambungan (Connection Lifecycle)**
|
|
35
131
|
|
|
36
|
-
|
|
132
|
+
- **connect**
|
|
37
133
|
|
|
38
|
-
|
|
134
|
+
- Mencuba log masuk berdasarkan parameter yang dikonfigurasi.
|
|
135
|
+
- Mengekalkan sesi dan menyimpan kuki untuk permintaan seterusnya.
|
|
39
136
|
|
|
40
|
-
- **
|
|
137
|
+
- **disconnect**
|
|
138
|
+
- Menamatkan sesi pelayar headless dan memadamkan kuki.
|
|
41
139
|
|
|
42
|
-
|
|
43
|
-
- Kolam akan menguruskan kitaran hidup contoh-contoh ini secara automatik, mencipta contoh baru jika diperlukan, dan menggunakan semula contoh sedia ada.
|
|
140
|
+
---
|
|
44
141
|
|
|
45
|
-
|
|
46
|
-
- Menghancurkan kolam pelayar tanpa kepala dan memastikan semua contoh ditutup dengan betul dan sumber dilepaskan.
|
|
142
|
+
## ⚡ **6. Tugas yang Disokong (Supported Tasks)**
|
|
47
143
|
|
|
48
|
-
|
|
144
|
+
| Jenis Tugas | Penerangan |
|
|
145
|
+
| ---------------------- | ---------------------------------------------- |
|
|
146
|
+
| `headless-pdf-capture` | Menukar HTML kepada PDF |
|
|
147
|
+
| `headless-scrap` | Mengekstrak data tertentu dari laman web |
|
|
148
|
+
| `headless-post` | Mengisi dan menghantar borang secara automatik |
|
|
49
149
|
|
|
50
|
-
|
|
150
|
+
#### 📌 **Contoh Penggunaan Tugas**
|
|
51
151
|
|
|
52
|
-
|
|
152
|
+
### 1️⃣ **Pengikisan Web (`headless-scrap`)**
|
|
53
153
|
|
|
54
|
-
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"name": "scrape-data",
|
|
157
|
+
"taskType": "headless-scrap",
|
|
158
|
+
"params": {
|
|
159
|
+
"path": "/products",
|
|
160
|
+
"selectors": [
|
|
161
|
+
{ "text": "Nama Produk", "value": ".product-title" },
|
|
162
|
+
{ "text": "Harga", "value": ".product-price" }
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
55
167
|
|
|
56
|
-
|
|
168
|
+
### 2️⃣ **Penjanaan PDF (`headless-pdf-capture`)**
|
|
57
169
|
|
|
58
170
|
```json
|
|
59
171
|
{
|
|
@@ -68,6 +180,42 @@ apabila diperlukan.
|
|
|
68
180
|
}
|
|
69
181
|
```
|
|
70
182
|
|
|
71
|
-
|
|
183
|
+
### 3️⃣ **Penghantaran Borang (`headless-post`)**
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"name": "submit-form",
|
|
188
|
+
"taskType": "headless-post",
|
|
189
|
+
"params": {
|
|
190
|
+
"formPath": "/contact",
|
|
191
|
+
"fields": {
|
|
192
|
+
"#name": "Ali Bin Ahmad",
|
|
193
|
+
"#email": "ali@example.com",
|
|
194
|
+
"#message": "Salam, ini adalah mesej ujian!"
|
|
195
|
+
},
|
|
196
|
+
"submitSelector": "#submit-button"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 📢 **7. Penerangan (Description)**
|
|
204
|
+
|
|
205
|
+
**Penyambung Headless** membolehkan **pengikisan web, log masuk automatik, penjanaan PDF, dan penghantaran borang** dilakukan secara automatik.
|
|
206
|
+
Ia menyokong kedua-dua **log masuk berdasarkan borang HTML** dan **log masuk API**, membolehkan sambungan yang stabil di pelbagai laman web.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### 📌 **Ringkasan**
|
|
211
|
+
|
|
212
|
+
| Fungsi | Penerangan |
|
|
213
|
+
| ------------------------- | --------------------------------------------------------- |
|
|
214
|
+
| **Log Masuk Borang HTML** | Mensimulasikan interaksi pengguna untuk log masuk |
|
|
215
|
+
| **Log Masuk API** | Menggunakan permintaan API untuk log masuk (lebih pantas) |
|
|
216
|
+
| **Penyelenggaraan Sesi** | Menyimpan kuki untuk memastikan sesi kekal aktif |
|
|
217
|
+
| **Pengikisan Web** | Mengekstrak data yang ditentukan secara automatik |
|
|
218
|
+
| **Penukaran PDF** | Menukar halaman HTML kepada format PDF |
|
|
219
|
+
| **Penghantaran Borang** | Mengisi dan menghantar borang secara automatik |
|
|
72
220
|
|
|
73
|
-
|
|
221
|
+
📌 **Gunakan Penyambung Headless untuk mengautomasikan pelbagai tugas web dengan lebih mudah dan cekap!** 🚀
|