dataapp-crawler-octoparse-browser 0.1.0__tar.gz

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.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.5
2
+ Name: dataapp-crawler-octoparse-browser
3
+ Version: 0.1.0
4
+ Summary: Octoparse browser providers for DataApp Crawler
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: dataapp-crawler<0.2,>=0.1.0
7
+ Requires-Dist: octoparse-relay<0.2,>=0.1.10
8
+ Requires-Dist: playwright<2,>=1.64
9
+ Provides-Extra: managed
10
+ Requires-Dist: dataapp-resource-proxy<0.2,>=0.1.0; extra == 'managed'
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Octoparse Crawler SDK
14
+
15
+ Octoparse browser providers for DataApp Crawler.
16
+
17
+ The accompanying browser-image source is maintained in
18
+ [`browserenv/`](browserenv/README.md). Python provider packages and the BrowserEnv
19
+ image share this repository but are built and released separately; BrowserEnv is
20
+ excluded from the Python wheel and sdist.
21
+
22
+ Install the browser package from the DataOS development index. It installs
23
+ Crawler and the Relay Python transport as dependencies. The Python import path
24
+ is `dataapp_crawler_octoparse`.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install --extra-index-url https://nexus.bazhuayu.com/repository/pypi-dataos-dev/simple/ \
30
+ dataapp-crawler-octoparse-browser==0.1.0.dev4
31
+ ```
32
+
33
+ ## Providers
34
+
35
+ - `BrowserEnvRelay` connects to the Relay browser supplied by the DataApp Relay image.
36
+ - `RelayBrowser` starts and owns a local browser, Relay extension, and Relay server.
37
+
38
+ ```python
39
+ from dataapp_crawler_octoparse import BrowserEnvRelay
40
+
41
+ browser = BrowserEnvRelay()
42
+ ```
43
+
44
+ The SDK's BrowserEnv image bundles CloakBrowser and runs it in headed mode,
45
+ using Xvfb when needed. Applications connect through `BrowserEnvRelay`.
46
+
47
+ `RelayBrowser` is an advanced self-managed path, not the Relay Data App template
48
+ default. A fresh post-fix local candidate batch passed full Relay pairing,
49
+ HTTP/HTTPS DOM work, owned-process cleanup, and container cleanup with Chrome
50
+ 151 in headless and Xvfb modes, CloakBrowser 146 headless, and Chromium 156
51
+ headless. Earlier Chrome pairing and CloakBrowser headless failures remain useful
52
+ pre-fix history, not the current result. These are versioned local candidate
53
+ checks, not universal browser or target-site guarantees; proxy combinations were
54
+ not repeated across every browser. The published clean `rc.3` template image is
55
+ a separate release artifact from the locally tested
56
+ `dataos-octoparse-integration:20261108-managed` candidate.
57
+
58
+ BrowserEnv proxy control uses `DATAAPP_BROWSER_PROXY_API_URL`,
59
+ `DATAAPP_BROWSER_PROXY_API_USERNAME`, and `DATAAPP_BROWSER_PROXY_API_PASSWORD`.
60
+ It also accepts the legacy `OCTOPUS_PROXY_SOFTWARE_API_*` settings when their
61
+ canonical equivalents are absent. The control endpoint must be HTTP on
62
+ loopback. An upstream `https://` proxy uses TLS with certificate and hostname
63
+ verification.
64
+
65
+ In a DataHub Run, choose `DataOSProxy(DataApp.resources())` as the
66
+ `DataAppCrawler` proxy provider to attribute browser traffic to the Run.
67
+ Select a lease duration that covers the browser work. Renewal depends on the
68
+ configured supplier.
69
+
70
+ ## CAPTCHA and images
71
+
72
+ AWS WAF image selection and controlled extension grants are internal C10/C07
73
+ experiments. The current platform Runtime does not expose their routes.
74
+ Direct local Resource Proxy experiments require matching Relay, extension and
75
+ server candidates. Local protocol checks do not establish real-site submission,
76
+ clearance, data collection or availability through a platform Run.
77
+
78
+ CAPTCHA solving is opt-in. Install the `managed` extra with the local candidate
79
+ Resource Proxy client. In local development, open `ResourceProxy.from_env()`;
80
+ platform applications use `DataApp.resources()` when the corresponding
81
+ Runtime/DataHub routes are enabled. Model routes still require that platform
82
+ integration; local support does not imply availability on pre.
83
+
84
+ For local managed-resource testing, save the current environment's DataOS API
85
+ Key in a regular text file containing exactly one non-empty line, then run:
86
+
87
+ ```bash
88
+ python -m dataapp_crawler run --api-key-file /path/to/api-key.txt -- python app.py
89
+ ```
90
+
91
+ The source file cannot be a symlink or directory. The local launcher reads it locally and injects it only into the child process. Resource Proxy
92
+ receives the normal Authorization header, never the source file. Do not paste the
93
+ Key into chat or package the source file with the App. Platform Runs use the
94
+ injected Runtime identity.
95
+
96
+ The typed API accepts embedded Turnstile, reCAPTCHA v2, Enterprise v2, and
97
+ image-to-text tasks. Widget tasks return `.token`; image tasks return `.text`.
98
+ Module selection chooses a recognizer for a known image technology, rather
99
+ than detecting what a website uses:
100
+
101
+ ```python
102
+ from dataapp_crawler.images import capture_image
103
+
104
+ image = await context.run(capture_image(page.locator("#captcha-image")))
105
+ task = await context.run(resources.solve_captcha(
106
+ type="image_to_text",
107
+ image_body=image.image_body,
108
+ capmonster_module="botdetect", # Only for a known BotDetect challenge.
109
+ ))
110
+ ```
111
+
112
+ `capture_image()` defaults to a visible rendered-element capture and does not
113
+ request a mutable image URL again. Chromium uses a clipped CDP screenshot when
114
+ available and otherwise falls back to the native Locator screenshot; hidden or
115
+ zero-size elements fail safely. When the developer has established that a
116
+ loaded `IMG` is the current challenge, `source="loaded_image"` explicitly copies
117
+ its pixels through Canvas without another GET and remains subject to cross-origin
118
+ pixel restrictions. The same image's `data_url` can be passed to
119
+ `resources.chat_completion()` as an inline model image. These small helpers do
120
+ not detect, solve, submit, or verify a challenge, and they do not turn `process`
121
+ into a processing framework. The developer still checks the
122
+ challenge identity, applies the candidate, checks the site verdict, and extracts
123
+ business data. Use the matching version's capability acceptance matrix to check
124
+ which task and site flows have been validated.
125
+
126
+ In the final real Relay check, default capture rejected the hidden zero-size IMG,
127
+ while explicit `loaded_image` returned its current PNG bytes without another
128
+ request. A visible wrapper capture no longer timed out, but that page's wrapper
129
+ pixels were blank; a successful screenshot therefore does not prove it contains
130
+ the challenge image or that a solver or site will accept it.
131
+
132
+ The managed cloud API through `DataApp.resources()` and Resource Proxy is the
133
+ default public solving path. Application code must explicitly create a bounded
134
+ task after the developer has enabled metered solving; CAPTCHA detection alone
135
+ never creates a paid task. In a local Runtime/DataHub resource-bridge acceptance,
136
+ the managed cloud API
137
+ passed one public reCAPTCHA Enterprise v2 demonstration form through real token
138
+ creation, browser submission, server acceptance, and Dataset output. BotDetect
139
+ image and vision-model candidates were submitted but rejected by the
140
+ demonstration site. Turnstile and regular reCAPTCHA v2 did not receive the same
141
+ acceptance test. Detection only classifies evidence; it does not solve a
142
+ challenge. None of these results establishes success on a business site.
143
+
144
+ ### Native CapMonster extension with a developer-owned key (advanced opt-in)
145
+
146
+ For trusted local development, a developer may explicitly configure
147
+ BrowserEnv's bundled native CapMonster extension before browser startup:
148
+
149
+ ```bash
150
+ # CAPMONSTER_API_KEY is already loaded from the developer's local secret store.
151
+ export CAPMONSTER_API_KEY
152
+ export CAPMONSTER_CAPTCHA_TYPES='ReCaptcha2,ReCaptchaEnterprise,Turnstile'
153
+ xvfb-run -a octoparse-relay-task -- uv run python app.py
154
+ ```
155
+
156
+ `CAPMONSTER_CAPTCHA_TYPES` is a comma-separated allowlist. Each selected type
157
+ must be supported by the extension bundle in the chosen image. The key belongs
158
+ to the developer and is not a shared platform key. Do not commit it, pass it as
159
+ a build argument, write it to logs or Dataset records, or expose it in errors.
160
+ The launcher prepares a private extension copy before browser startup and removes
161
+ the two variables from the child application environment; the key still enters
162
+ the third-party extension context.
163
+
164
+ This BYOK path is currently limited to trusted local sessions. The launcher
165
+ rejects raw CapMonster keys when DataHub platform identity is present, so this
166
+ configuration is not a supported production DataApp path. A Resource Proxy
167
+ grant-backed automatic extension integration is under development and is not a
168
+ public product API. Use the explicit managed cloud API where platform credential
169
+ isolation is required. Do not run native automatic solving and explicit API
170
+ solving against the same challenge. Native Enterprise end-to-end site acceptance
171
+ has not yet been established.
172
+
173
+ ## Documentation and examples
174
+
175
+ The Relay project template ships the following together:
176
+
177
+ - [Developer guide](../../examples/crawler/relay_template/help/docs/DEVELOPER_GUIDE.zh-CN.md):
178
+ browser lifecycles, extension input behavior, fingerprints, proxies, and limits.
179
+ - [API reference](../../examples/crawler/relay_template/help/docs/API.zh-CN.md): Provider,
180
+ Crawler helper, and advanced low-level Relay signatures and return values.
181
+ - [Importable scenarios](../../examples/crawler/relay_template/help/examples/README.md):
182
+ pointer observation, scoped navigation, readiness, and extraction.
183
+ - [Complete search/list/detail flow](../../examples/crawler/relay_template/site_adapter.py):
184
+ the site's business flow used by the Runtime `app.py` entry.
185
+
186
+ `Page` and `Locator` remain native Playwright objects. Pointer trajectory handling
187
+ is implemented by the extension; it is not an additional Python `human_click()`
188
+ method. Browser fingerprint behavior belongs to the selected browser environment.
@@ -0,0 +1,176 @@
1
+ # Octoparse Crawler SDK
2
+
3
+ Octoparse browser providers for DataApp Crawler.
4
+
5
+ The accompanying browser-image source is maintained in
6
+ [`browserenv/`](browserenv/README.md). Python provider packages and the BrowserEnv
7
+ image share this repository but are built and released separately; BrowserEnv is
8
+ excluded from the Python wheel and sdist.
9
+
10
+ Install the browser package from the DataOS development index. It installs
11
+ Crawler and the Relay Python transport as dependencies. The Python import path
12
+ is `dataapp_crawler_octoparse`.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install --extra-index-url https://nexus.bazhuayu.com/repository/pypi-dataos-dev/simple/ \
18
+ dataapp-crawler-octoparse-browser==0.1.0.dev4
19
+ ```
20
+
21
+ ## Providers
22
+
23
+ - `BrowserEnvRelay` connects to the Relay browser supplied by the DataApp Relay image.
24
+ - `RelayBrowser` starts and owns a local browser, Relay extension, and Relay server.
25
+
26
+ ```python
27
+ from dataapp_crawler_octoparse import BrowserEnvRelay
28
+
29
+ browser = BrowserEnvRelay()
30
+ ```
31
+
32
+ The SDK's BrowserEnv image bundles CloakBrowser and runs it in headed mode,
33
+ using Xvfb when needed. Applications connect through `BrowserEnvRelay`.
34
+
35
+ `RelayBrowser` is an advanced self-managed path, not the Relay Data App template
36
+ default. A fresh post-fix local candidate batch passed full Relay pairing,
37
+ HTTP/HTTPS DOM work, owned-process cleanup, and container cleanup with Chrome
38
+ 151 in headless and Xvfb modes, CloakBrowser 146 headless, and Chromium 156
39
+ headless. Earlier Chrome pairing and CloakBrowser headless failures remain useful
40
+ pre-fix history, not the current result. These are versioned local candidate
41
+ checks, not universal browser or target-site guarantees; proxy combinations were
42
+ not repeated across every browser. The published clean `rc.3` template image is
43
+ a separate release artifact from the locally tested
44
+ `dataos-octoparse-integration:20261108-managed` candidate.
45
+
46
+ BrowserEnv proxy control uses `DATAAPP_BROWSER_PROXY_API_URL`,
47
+ `DATAAPP_BROWSER_PROXY_API_USERNAME`, and `DATAAPP_BROWSER_PROXY_API_PASSWORD`.
48
+ It also accepts the legacy `OCTOPUS_PROXY_SOFTWARE_API_*` settings when their
49
+ canonical equivalents are absent. The control endpoint must be HTTP on
50
+ loopback. An upstream `https://` proxy uses TLS with certificate and hostname
51
+ verification.
52
+
53
+ In a DataHub Run, choose `DataOSProxy(DataApp.resources())` as the
54
+ `DataAppCrawler` proxy provider to attribute browser traffic to the Run.
55
+ Select a lease duration that covers the browser work. Renewal depends on the
56
+ configured supplier.
57
+
58
+ ## CAPTCHA and images
59
+
60
+ AWS WAF image selection and controlled extension grants are internal C10/C07
61
+ experiments. The current platform Runtime does not expose their routes.
62
+ Direct local Resource Proxy experiments require matching Relay, extension and
63
+ server candidates. Local protocol checks do not establish real-site submission,
64
+ clearance, data collection or availability through a platform Run.
65
+
66
+ CAPTCHA solving is opt-in. Install the `managed` extra with the local candidate
67
+ Resource Proxy client. In local development, open `ResourceProxy.from_env()`;
68
+ platform applications use `DataApp.resources()` when the corresponding
69
+ Runtime/DataHub routes are enabled. Model routes still require that platform
70
+ integration; local support does not imply availability on pre.
71
+
72
+ For local managed-resource testing, save the current environment's DataOS API
73
+ Key in a regular text file containing exactly one non-empty line, then run:
74
+
75
+ ```bash
76
+ python -m dataapp_crawler run --api-key-file /path/to/api-key.txt -- python app.py
77
+ ```
78
+
79
+ The source file cannot be a symlink or directory. The local launcher reads it locally and injects it only into the child process. Resource Proxy
80
+ receives the normal Authorization header, never the source file. Do not paste the
81
+ Key into chat or package the source file with the App. Platform Runs use the
82
+ injected Runtime identity.
83
+
84
+ The typed API accepts embedded Turnstile, reCAPTCHA v2, Enterprise v2, and
85
+ image-to-text tasks. Widget tasks return `.token`; image tasks return `.text`.
86
+ Module selection chooses a recognizer for a known image technology, rather
87
+ than detecting what a website uses:
88
+
89
+ ```python
90
+ from dataapp_crawler.images import capture_image
91
+
92
+ image = await context.run(capture_image(page.locator("#captcha-image")))
93
+ task = await context.run(resources.solve_captcha(
94
+ type="image_to_text",
95
+ image_body=image.image_body,
96
+ capmonster_module="botdetect", # Only for a known BotDetect challenge.
97
+ ))
98
+ ```
99
+
100
+ `capture_image()` defaults to a visible rendered-element capture and does not
101
+ request a mutable image URL again. Chromium uses a clipped CDP screenshot when
102
+ available and otherwise falls back to the native Locator screenshot; hidden or
103
+ zero-size elements fail safely. When the developer has established that a
104
+ loaded `IMG` is the current challenge, `source="loaded_image"` explicitly copies
105
+ its pixels through Canvas without another GET and remains subject to cross-origin
106
+ pixel restrictions. The same image's `data_url` can be passed to
107
+ `resources.chat_completion()` as an inline model image. These small helpers do
108
+ not detect, solve, submit, or verify a challenge, and they do not turn `process`
109
+ into a processing framework. The developer still checks the
110
+ challenge identity, applies the candidate, checks the site verdict, and extracts
111
+ business data. Use the matching version's capability acceptance matrix to check
112
+ which task and site flows have been validated.
113
+
114
+ In the final real Relay check, default capture rejected the hidden zero-size IMG,
115
+ while explicit `loaded_image` returned its current PNG bytes without another
116
+ request. A visible wrapper capture no longer timed out, but that page's wrapper
117
+ pixels were blank; a successful screenshot therefore does not prove it contains
118
+ the challenge image or that a solver or site will accept it.
119
+
120
+ The managed cloud API through `DataApp.resources()` and Resource Proxy is the
121
+ default public solving path. Application code must explicitly create a bounded
122
+ task after the developer has enabled metered solving; CAPTCHA detection alone
123
+ never creates a paid task. In a local Runtime/DataHub resource-bridge acceptance,
124
+ the managed cloud API
125
+ passed one public reCAPTCHA Enterprise v2 demonstration form through real token
126
+ creation, browser submission, server acceptance, and Dataset output. BotDetect
127
+ image and vision-model candidates were submitted but rejected by the
128
+ demonstration site. Turnstile and regular reCAPTCHA v2 did not receive the same
129
+ acceptance test. Detection only classifies evidence; it does not solve a
130
+ challenge. None of these results establishes success on a business site.
131
+
132
+ ### Native CapMonster extension with a developer-owned key (advanced opt-in)
133
+
134
+ For trusted local development, a developer may explicitly configure
135
+ BrowserEnv's bundled native CapMonster extension before browser startup:
136
+
137
+ ```bash
138
+ # CAPMONSTER_API_KEY is already loaded from the developer's local secret store.
139
+ export CAPMONSTER_API_KEY
140
+ export CAPMONSTER_CAPTCHA_TYPES='ReCaptcha2,ReCaptchaEnterprise,Turnstile'
141
+ xvfb-run -a octoparse-relay-task -- uv run python app.py
142
+ ```
143
+
144
+ `CAPMONSTER_CAPTCHA_TYPES` is a comma-separated allowlist. Each selected type
145
+ must be supported by the extension bundle in the chosen image. The key belongs
146
+ to the developer and is not a shared platform key. Do not commit it, pass it as
147
+ a build argument, write it to logs or Dataset records, or expose it in errors.
148
+ The launcher prepares a private extension copy before browser startup and removes
149
+ the two variables from the child application environment; the key still enters
150
+ the third-party extension context.
151
+
152
+ This BYOK path is currently limited to trusted local sessions. The launcher
153
+ rejects raw CapMonster keys when DataHub platform identity is present, so this
154
+ configuration is not a supported production DataApp path. A Resource Proxy
155
+ grant-backed automatic extension integration is under development and is not a
156
+ public product API. Use the explicit managed cloud API where platform credential
157
+ isolation is required. Do not run native automatic solving and explicit API
158
+ solving against the same challenge. Native Enterprise end-to-end site acceptance
159
+ has not yet been established.
160
+
161
+ ## Documentation and examples
162
+
163
+ The Relay project template ships the following together:
164
+
165
+ - [Developer guide](../../examples/crawler/relay_template/help/docs/DEVELOPER_GUIDE.zh-CN.md):
166
+ browser lifecycles, extension input behavior, fingerprints, proxies, and limits.
167
+ - [API reference](../../examples/crawler/relay_template/help/docs/API.zh-CN.md): Provider,
168
+ Crawler helper, and advanced low-level Relay signatures and return values.
169
+ - [Importable scenarios](../../examples/crawler/relay_template/help/examples/README.md):
170
+ pointer observation, scoped navigation, readiness, and extraction.
171
+ - [Complete search/list/detail flow](../../examples/crawler/relay_template/site_adapter.py):
172
+ the site's business flow used by the Runtime `app.py` entry.
173
+
174
+ `Page` and `Locator` remain native Playwright objects. Pointer trajectory handling
175
+ is implemented by the extension; it is not an additional Python `human_click()`
176
+ method. Browser fingerprint behavior belongs to the selected browser environment.
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dataapp-crawler-octoparse-browser"
7
+ version = "0.1.0"
8
+ description = "Octoparse browser providers for DataApp Crawler"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ dependencies = [
12
+ "dataapp-crawler>=0.1.0,<0.2",
13
+ "playwright>=1.64,<2",
14
+ "octoparse-relay>=0.1.10,<0.2",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ managed = ["dataapp-resource-proxy>=0.1.0,<0.2"]
19
+
20
+ [tool.uv.sources]
21
+ dataapp-crawler = {path = "../crawler", editable = true}
22
+ octoparse-relay = {path = "../../../relay", editable = true}
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/dataapp_crawler_octoparse"]
26
+
27
+ [tool.hatch.build.targets.sdist]
28
+ only-include = ["src", "README.md", "pyproject.toml"]
29
+
30
+ [tool.ruff]
31
+ target-version = "py311"
32
+ line-length = 100
33
+
34
+ [tool.ruff.lint]
35
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,13 @@
1
+ """Octoparse browser provider extension for DataApp Crawler."""
2
+
3
+ from .browserenv import BrowserEnvRelay
4
+ from .captcha import CaptchaType, ManagedCaptchaPlugin, PreparedCaptchaExtension
5
+ from .relay import RelayBrowser
6
+
7
+ __all__ = [
8
+ "BrowserEnvRelay",
9
+ "CaptchaType",
10
+ "ManagedCaptchaPlugin",
11
+ "PreparedCaptchaExtension",
12
+ "RelayBrowser",
13
+ ]