hamro-scrapy-playwright 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,164 @@
1
+ .mise.toml
2
+ .nvim.lua
3
+ storage
4
+
5
+ # The rest is copied from https://github.com/github/gitignore/blob/main/Python.gitignore
6
+
7
+ # Byte-compiled / optimized / DLL files
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+
12
+ # C extensions
13
+ *.so
14
+
15
+ # Distribution / packaging
16
+ .Python
17
+ build/
18
+ develop-eggs/
19
+ dist/
20
+ downloads/
21
+ eggs/
22
+ .eggs/
23
+ lib/
24
+ lib64/
25
+ parts/
26
+ sdist/
27
+ var/
28
+ wheels/
29
+ share/python-wheels/
30
+ *.egg-info/
31
+ .installed.cfg
32
+ *.egg
33
+ MANIFEST
34
+
35
+ # PyInstaller
36
+ # Usually these files are written by a python script from a template
37
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
38
+ *.manifest
39
+ *.spec
40
+
41
+ # Installer logs
42
+ pip-log.txt
43
+ pip-delete-this-directory.txt
44
+
45
+ # Unit test / coverage reports
46
+ htmlcov/
47
+ .tox/
48
+ .nox/
49
+ .coverage
50
+ .coverage.*
51
+ .cache
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ *.py,cover
56
+ .hypothesis/
57
+ .pytest_cache/
58
+ cover/
59
+
60
+ # Translations
61
+ *.mo
62
+ *.pot
63
+
64
+ # Django stuff:
65
+ *.log
66
+ local_settings.py
67
+ db.sqlite3
68
+ db.sqlite3-journal
69
+
70
+ # Flask stuff:
71
+ instance/
72
+ .webassets-cache
73
+
74
+ # Scrapy stuff:
75
+ .scrapy
76
+
77
+ # Sphinx documentation
78
+ docs/_build/
79
+
80
+ # PyBuilder
81
+ .pybuilder/
82
+ target/
83
+
84
+ # Jupyter Notebook
85
+ .ipynb_checkpoints
86
+
87
+ # IPython
88
+ profile_default/
89
+ ipython_config.py
90
+
91
+ # pyenv
92
+ # For a library or package, you might want to ignore these files since the code is
93
+ # intended to run in multiple environments; otherwise, check them in:
94
+ .python-version
95
+
96
+ # pdm
97
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
98
+ #pdm.lock
99
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
100
+ # in version control.
101
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
102
+ .pdm.toml
103
+ .pdm-python
104
+ .pdm-build/
105
+
106
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
107
+ __pypackages__/
108
+
109
+ # Celery stuff
110
+ celerybeat-schedule
111
+ celerybeat.pid
112
+
113
+ # SageMath parsed files
114
+ *.sage.py
115
+
116
+ # Environments
117
+ .env
118
+ .venv
119
+ env/
120
+ venv/
121
+ ENV/
122
+ env.bak/
123
+ venv.bak/
124
+
125
+ # Spyder project settings
126
+ .spyderproject
127
+ .spyproject
128
+
129
+ # Rope project settings
130
+ .ropeproject
131
+
132
+ # mkdocs documentation
133
+ /site
134
+
135
+ # mypy
136
+ .mypy_cache/
137
+ .dmypy.json
138
+ dmypy.json
139
+
140
+ # Pyre type checker
141
+ .pyre/
142
+
143
+ # pytype static type analyzer
144
+ .pytype/
145
+
146
+ # Cython debug symbols
147
+ cython_debug/
148
+
149
+ # PyCharm
150
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
151
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
152
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
153
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
154
+ .idea/
155
+
156
+ # Visual Studio Code
157
+ # Ignores the folder created by VS Code when changing workspace settings, doing debugger
158
+ # configuration, etc. Can be commented out to share Workspace Settings within a team
159
+ .vscode
160
+
161
+ # Zed editor
162
+ # Ignores the folder created when setting Project Settings in the Zed editor. Can be commented out
163
+ # to share Project Settings within a team
164
+ .zed
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hamro-scrapy-playwright contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: hamro-scrapy-playwright
3
+ Version: 0.1.0
4
+ Summary: Thin extension layer that integrates a pinned custom Chromium build into scrapy-playwright.
5
+ Project-URL: Homepage, https://github.com/jyabadesk/hamro-scrapy-playwright
6
+ Project-URL: Repository, https://github.com/jyabadesk/hamro-scrapy-playwright
7
+ Project-URL: Issues, https://github.com/jyabadesk/hamro-scrapy-playwright/issues
8
+ Author: hamro-scrapy-playwright contributors
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: chromium,headless,playwright,scraping,scrapy
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: Scrapy
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: httpx>=0.28.0
26
+ Requires-Dist: playwright>=1.40.0
27
+ Requires-Dist: scrapy-playwright>=0.0.46
28
+ Description-Content-Type: text/markdown
29
+
30
+ # hamro-scrapy-playwright
31
+
32
+ Thin extension layer that integrates a **pinned custom Chromium build** directly into [scrapy-playwright](https://github.com/scrapy-plugins/scrapy-playwright).
33
+
34
+ Users only need to swap the Scrapy download handler — existing spiders with `meta={"playwright": True}` keep working unchanged.
35
+
36
+ ## Architecture
37
+
38
+ ```text
39
+ Scrapy
40
+
41
+
42
+ CustomChromiumDownloadHandler
43
+
44
+
45
+ ScrapyPlaywrightDownloadHandler
46
+
47
+
48
+ Playwright
49
+
50
+
51
+ Custom Chromium Binary
52
+ ```
53
+
54
+ * Subclasses `ScrapyPlaywrightDownloadHandler`, overrides only `_launch()`.
55
+ * Firefox and WebKit are delegated to upstream scrapy-playwright untouched.
56
+
57
+ ## Requirements
58
+
59
+ | Requirement | Version |
60
+ |---|---|
61
+ | Python | ≥ 3.11 |
62
+ | OS | Linux x86_64 |
63
+ | scrapy-playwright | ≥ 0.0.46 |
64
+ | playwright | ≥ 1.40.0 |
65
+ | httpx | ≥ 0.28.0 |
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install hamro-scrapy-playwright
71
+ ```
72
+
73
+ Or install from source:
74
+
75
+ ```bash
76
+ git clone https://github.com/jyabadesk/hamro-scrapy-playwright.git
77
+ cd hamro-scrapy-playwright
78
+ pip install .
79
+ ```
80
+
81
+ ## Usage
82
+
83
+ In your Scrapy project's `settings.py`:
84
+
85
+ ```python
86
+ DOWNLOAD_HANDLERS = {
87
+ "http": "scrapy_playwright_custom.handler.CustomChromiumDownloadHandler",
88
+ "https": "scrapy_playwright_custom.handler.CustomChromiumDownloadHandler",
89
+ }
90
+
91
+ TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
92
+
93
+ # Optional: configure Playwright as usual
94
+ PLAYWRIGHT_LAUNCH_OPTIONS = {
95
+ "headless": True,
96
+ }
97
+ ```
98
+
99
+ That's it. Your spiders keep working unchanged:
100
+
101
+ ```python
102
+ import scrapy
103
+
104
+
105
+ class ExampleSpider(scrapy.Spider):
106
+ name = "example"
107
+ start_urls = ["https://example.com"]
108
+
109
+ def start_requests(self):
110
+ for url in self.start_urls:
111
+ yield scrapy.Request(url, meta={"playwright": True})
112
+
113
+ def parse(self, response):
114
+ self.logger.info("Title: %s", response.css("title::text").get())
115
+ ```
116
+
117
+ ## How It Works
118
+
119
+ 1. **Platform check** — raises `RuntimeError` on anything other than Linux x86_64.
120
+ 2. **Download** — streams the pinned Chromium archive from GitHub Releases (with retries and progress).
121
+ 3. **Verify** — mandatory SHA-256 checksum comparison; raises on mismatch.
122
+ 4. **Extract** — safe `tar.gz` extraction with path-traversal and symlink protection.
123
+ 5. **Discover** — locates the `chrome` / `chromium` executable inside the extracted tree.
124
+ 6. **Inject** — wraps Playwright's chromium `BrowserType` to always use the custom binary.
125
+ 7. **Launch args** — merges default anti-detection flags with any user-provided arguments.
126
+
127
+ Browser files are stored in `~/.hamro-browser/`, never inside `site-packages`.
128
+
129
+ ```text
130
+ ~/.hamro-browser/
131
+ ├── browser/ # extracted Chromium
132
+ ├── downloads/ # cached archive
133
+ ├── metadata.json # installed version + executable path
134
+ └── checksum # SHA-256 digest
135
+ ```
136
+
137
+ ## Non-Chromium Browsers
138
+
139
+ When `PLAYWRIGHT_BROWSER_TYPE` is set to `firefox`, the handler throws a `RuntimeError` as only `chromium` is supported (and `webkit` is delegated to upstream scrapy-playwright with zero changes).
140
+
141
+ ## Building
142
+
143
+ ```bash
144
+ pip install build
145
+ python -m build
146
+ ```
147
+
148
+ ## License
149
+
150
+ MIT
@@ -0,0 +1,121 @@
1
+ # hamro-scrapy-playwright
2
+
3
+ Thin extension layer that integrates a **pinned custom Chromium build** directly into [scrapy-playwright](https://github.com/scrapy-plugins/scrapy-playwright).
4
+
5
+ Users only need to swap the Scrapy download handler — existing spiders with `meta={"playwright": True}` keep working unchanged.
6
+
7
+ ## Architecture
8
+
9
+ ```text
10
+ Scrapy
11
+
12
+
13
+ CustomChromiumDownloadHandler
14
+
15
+
16
+ ScrapyPlaywrightDownloadHandler
17
+
18
+
19
+ Playwright
20
+
21
+
22
+ Custom Chromium Binary
23
+ ```
24
+
25
+ * Subclasses `ScrapyPlaywrightDownloadHandler`, overrides only `_launch()`.
26
+ * Firefox and WebKit are delegated to upstream scrapy-playwright untouched.
27
+
28
+ ## Requirements
29
+
30
+ | Requirement | Version |
31
+ |---|---|
32
+ | Python | ≥ 3.11 |
33
+ | OS | Linux x86_64 |
34
+ | scrapy-playwright | ≥ 0.0.46 |
35
+ | playwright | ≥ 1.40.0 |
36
+ | httpx | ≥ 0.28.0 |
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install hamro-scrapy-playwright
42
+ ```
43
+
44
+ Or install from source:
45
+
46
+ ```bash
47
+ git clone https://github.com/jyabadesk/hamro-scrapy-playwright.git
48
+ cd hamro-scrapy-playwright
49
+ pip install .
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ In your Scrapy project's `settings.py`:
55
+
56
+ ```python
57
+ DOWNLOAD_HANDLERS = {
58
+ "http": "scrapy_playwright_custom.handler.CustomChromiumDownloadHandler",
59
+ "https": "scrapy_playwright_custom.handler.CustomChromiumDownloadHandler",
60
+ }
61
+
62
+ TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
63
+
64
+ # Optional: configure Playwright as usual
65
+ PLAYWRIGHT_LAUNCH_OPTIONS = {
66
+ "headless": True,
67
+ }
68
+ ```
69
+
70
+ That's it. Your spiders keep working unchanged:
71
+
72
+ ```python
73
+ import scrapy
74
+
75
+
76
+ class ExampleSpider(scrapy.Spider):
77
+ name = "example"
78
+ start_urls = ["https://example.com"]
79
+
80
+ def start_requests(self):
81
+ for url in self.start_urls:
82
+ yield scrapy.Request(url, meta={"playwright": True})
83
+
84
+ def parse(self, response):
85
+ self.logger.info("Title: %s", response.css("title::text").get())
86
+ ```
87
+
88
+ ## How It Works
89
+
90
+ 1. **Platform check** — raises `RuntimeError` on anything other than Linux x86_64.
91
+ 2. **Download** — streams the pinned Chromium archive from GitHub Releases (with retries and progress).
92
+ 3. **Verify** — mandatory SHA-256 checksum comparison; raises on mismatch.
93
+ 4. **Extract** — safe `tar.gz` extraction with path-traversal and symlink protection.
94
+ 5. **Discover** — locates the `chrome` / `chromium` executable inside the extracted tree.
95
+ 6. **Inject** — wraps Playwright's chromium `BrowserType` to always use the custom binary.
96
+ 7. **Launch args** — merges default anti-detection flags with any user-provided arguments.
97
+
98
+ Browser files are stored in `~/.hamro-browser/`, never inside `site-packages`.
99
+
100
+ ```text
101
+ ~/.hamro-browser/
102
+ ├── browser/ # extracted Chromium
103
+ ├── downloads/ # cached archive
104
+ ├── metadata.json # installed version + executable path
105
+ └── checksum # SHA-256 digest
106
+ ```
107
+
108
+ ## Non-Chromium Browsers
109
+
110
+ When `PLAYWRIGHT_BROWSER_TYPE` is set to `firefox`, the handler throws a `RuntimeError` as only `chromium` is supported (and `webkit` is delegated to upstream scrapy-playwright with zero changes).
111
+
112
+ ## Building
113
+
114
+ ```bash
115
+ pip install build
116
+ python -m build
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
@@ -0,0 +1,60 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hamro-scrapy-playwright"
7
+ version = "0.1.0"
8
+ description = "Thin extension layer that integrates a pinned custom Chromium build into scrapy-playwright."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ { name = "hamro-scrapy-playwright contributors" },
14
+ ]
15
+ keywords = [
16
+ "scrapy",
17
+ "playwright",
18
+ "chromium",
19
+ "scraping",
20
+ "headless",
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Framework :: Scrapy",
25
+ "Intended Audience :: Developers",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: POSIX :: Linux",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Topic :: Internet :: WWW/HTTP",
33
+ "Topic :: Software Development :: Libraries :: Python Modules",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = [
37
+ "scrapy-playwright>=0.0.46",
38
+ "playwright>=1.40.0",
39
+ "httpx>=0.28.0",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/jyabadesk/hamro-scrapy-playwright"
44
+ Repository = "https://github.com/jyabadesk/hamro-scrapy-playwright"
45
+ Issues = "https://github.com/jyabadesk/hamro-scrapy-playwright/issues"
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ packages = ["scrapy_playwright_custom"]
49
+
50
+ [tool.mypy]
51
+ python_version = "3.11"
52
+ strict = true
53
+ warn_return_any = true
54
+ warn_unused_configs = true
55
+ disallow_untyped_defs = true
56
+ disallow_incomplete_defs = true
57
+
58
+ [tool.pytest.ini_options]
59
+ asyncio_mode = "auto"
60
+ testpaths = ["tests"]
@@ -0,0 +1,3 @@
1
+ """hamro-scrapy-playwright: pinned custom Chromium for scrapy-playwright."""
2
+
3
+ __version__: str = "0.1.0"