bytecrawl 1.0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abraham Pérez
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,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: bytecrawl
3
+ Version: 1.0.0
4
+ Summary: Focused crawling for LLM data collection: Shark-Search and OPIC crawlers plus a single scraping API (static HTML, dynamic JS, APIs, session login, Markdown for LLMs) on a 3-dependency core.
5
+ Author-email: abrahamperz <aperez@adokmx.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/abrahamperz/ByteCrawl
8
+ Project-URL: Repository, https://github.com/abrahamperz/ByteCrawl
9
+ Keywords: scraping,crawler,focused-crawling,shark-search,opic,pagerank,beautifulsoup,playwright,markdown,llm
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
14
+ Classifier: Intended Audience :: Developers
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: requests>=2.28
19
+ Requires-Dist: beautifulsoup4>=4.11
20
+ Requires-Dist: lxml>=4.9
21
+ Provides-Extra: browser
22
+ Requires-Dist: playwright>=1.40; extra == "browser"
23
+ Provides-Extra: llm
24
+ Requires-Dist: markdownify>=0.11; extra == "llm"
25
+ Requires-Dist: trafilatura>=1.6; extra == "llm"
26
+ Provides-Extra: mcp
27
+ Requires-Dist: mcp>=2; python_version >= "3.10" and extra == "mcp"
28
+ Requires-Dist: markdownify>=0.11; extra == "mcp"
29
+ Requires-Dist: trafilatura>=1.6; extra == "mcp"
30
+ Provides-Extra: all
31
+ Requires-Dist: playwright>=1.40; extra == "all"
32
+ Requires-Dist: markdownify>=0.11; extra == "all"
33
+ Requires-Dist: trafilatura>=1.6; extra == "all"
34
+ Requires-Dist: mcp>=2; python_version >= "3.10" and extra == "all"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=7; extra == "dev"
37
+ Requires-Dist: pytest-cov; extra == "dev"
38
+ Requires-Dist: ruff; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # ByteCrawl
42
+
43
+ [![CI](https://github.com/abrahamperz/ByteCrawl/actions/workflows/ci.yml/badge.svg)](https://github.com/abrahamperz/ByteCrawl/actions/workflows/ci.yml)
44
+ [![PyPI](https://img.shields.io/pypi/v/bytecrawl)](https://pypi.org/project/bytecrawl/)
45
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue)](https://pypi.org/project/bytecrawl/)
46
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
47
+
48
+ **Give your AI agent focused web crawling.** ByteCrawl is an MCP server (and a
49
+ small Python library) that doesn't just scrape a page — it crawls a whole site
50
+ and returns the pages *most relevant* to your topic first, using Shark-Search
51
+ and OPIC in pure Python.
52
+
53
+ - **Webpage**: https://bytecrawl.vercel.app/
54
+ - **Hosted MCP endpoint**: https://bytecrawl.vercel.app/mcp
55
+
56
+ ## Quick start (MCP — nothing to install)
57
+
58
+ Point any MCP-capable agent (Claude Code, Claude Desktop, Cursor...) at the
59
+ hosted endpoint:
60
+
61
+ ```bash
62
+ claude mcp add --transport http bytecrawl https://bytecrawl.vercel.app/mcp
63
+ ```
64
+
65
+ Now the agent has four tools:
66
+
67
+ | Tool | What it does |
68
+ |---|---|
69
+ | `focused_crawl` | Crawl a site, rank pages by relevance to a query (Shark-Search / OPIC / BFS) |
70
+ | `fetch_markdown` | One page → clean Markdown (5–10× fewer tokens than raw HTML) |
71
+ | `extract` | Structured records via CSS selectors |
72
+ | `fetch_json_api` | Hit a hidden JSON API |
73
+
74
+ The hosted server is static-only, rate-limited per IP, caps crawls at 10 pages,
75
+ and refuses non-public URLs (SSRF guard). For heavy use or JS-rendered sites,
76
+ run it locally:
77
+
78
+ ```bash
79
+ pip install bytecrawl[mcp]
80
+ claude mcp add bytecrawl -- bytecrawl-mcp # full power, on your machine
81
+ pip install bytecrawl[browser] && playwright install chromium # + JS rendering
82
+ ```
83
+
84
+ ## Why focused crawling?
85
+
86
+ Most crawlers visit pages in whatever order they find them. With a limited
87
+ request budget, order is everything — Shark-Search chases the branches that
88
+ smell like your query and lets the rest decay, so 100 requests get you the 100
89
+ *most useful* pages, not the 100 closest to the seed.
90
+
91
+ ```python
92
+ from bytecrawl import SharkSearch
93
+
94
+ result = SharkSearch(query="vector databases").crawl(
95
+ "https://example.com", max_pages=100)
96
+
97
+ for page in result.top(10):
98
+ print(f'{page["relevance"]:.3f} {page["url"]}')
99
+ ```
100
+
101
+ - **BFS** — level by level, closest to the seed first.
102
+ - **Shark-Search** (Hersovici et al., 1998) — topical best-first; links inherit
103
+ their parent's relevance with decay.
104
+ - **OPIC** (Abiteboul et al., 2003) — live PageRank via "cash" flow, no full
105
+ graph needed (a `pagerank()` implementation is included to compare against).
106
+
107
+ Versus the alternatives: Scrapy is a framework you wire up yourself, Firecrawl
108
+ is a paid SaaS — ByteCrawl is a plain library with a 3-package core and these
109
+ frontier strategies built in.
110
+
111
+ ## Library API
112
+
113
+ ```python
114
+ from bytecrawl import Scraper
115
+
116
+ bot = Scraper()
117
+ page = bot.fetch("https://books.toscrape.com") # auto: static, browser fallback
118
+ books = page.extract("article.product_pod",
119
+ {"title": "h3 a::attr(title)", "price": "p.price_color::text"})
120
+ page.markdown() # clean Markdown for LLMs · page.tokens() # token estimate
121
+ ```
122
+
123
+ ```python
124
+ bot.static(url) # plain HTML
125
+ bot.api(url, params={...}) # hidden JSON API
126
+ bot.browser(url, wait="div.results") # JS via Playwright
127
+ bot.crawl(url, item="article", fields={...},
128
+ next_page="li.next a::attr(href)") # pagination
129
+ bot.session().login(url, data, csrf_field="csrf_token") # authenticated
130
+ ```
131
+
132
+ ## Install
133
+
134
+ ```bash
135
+ pip install bytecrawl # slim core (requests + beautifulsoup4 + lxml)
136
+ pip install bytecrawl[llm] # + Markdown for LLMs
137
+ pip install bytecrawl[browser] # + Playwright
138
+ pip install bytecrawl[mcp] # + local MCP server
139
+ pip install bytecrawl[all]
140
+ ```
141
+
142
+ ## Learn each scraping technique
143
+
144
+ A guided walkthrough with a runnable example against a practice site:
145
+ [static HTML](docs/01-html-estatico.md) ·
146
+ [dynamic JS](docs/02-js-dinamico.md) ·
147
+ [hidden APIs](docs/03-api-oculta.md) ·
148
+ [pagination](docs/04-crawling-paginacion.md) ·
149
+ [login](docs/05-login-sesion.md) ·
150
+ [graph crawling](docs/06-crawling-grafos.md) ·
151
+ [Markdown for LLMs](docs/markdown-llms.md) ·
152
+ [ethics](docs/nota-etica.md)
153
+
154
+ ## Contributing
155
+
156
+ ```bash
157
+ pip install -e ".[llm,dev,mcp]"
158
+ pytest # 109 tests, no network required
159
+ pytest -m live # + live browser tests (needs the browser extra)
160
+ ruff check bytecrawl tests
161
+ ```
162
+
163
+ Scrape responsibly: respect `robots.txt`, terms of service and rate limits.
164
+ ByteCrawl ships with a configurable delay between requests.
165
+
166
+ ## License
167
+
168
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,128 @@
1
+ # ByteCrawl
2
+
3
+ [![CI](https://github.com/abrahamperz/ByteCrawl/actions/workflows/ci.yml/badge.svg)](https://github.com/abrahamperz/ByteCrawl/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/bytecrawl)](https://pypi.org/project/bytecrawl/)
5
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue)](https://pypi.org/project/bytecrawl/)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
7
+
8
+ **Give your AI agent focused web crawling.** ByteCrawl is an MCP server (and a
9
+ small Python library) that doesn't just scrape a page — it crawls a whole site
10
+ and returns the pages *most relevant* to your topic first, using Shark-Search
11
+ and OPIC in pure Python.
12
+
13
+ - **Webpage**: https://bytecrawl.vercel.app/
14
+ - **Hosted MCP endpoint**: https://bytecrawl.vercel.app/mcp
15
+
16
+ ## Quick start (MCP — nothing to install)
17
+
18
+ Point any MCP-capable agent (Claude Code, Claude Desktop, Cursor...) at the
19
+ hosted endpoint:
20
+
21
+ ```bash
22
+ claude mcp add --transport http bytecrawl https://bytecrawl.vercel.app/mcp
23
+ ```
24
+
25
+ Now the agent has four tools:
26
+
27
+ | Tool | What it does |
28
+ |---|---|
29
+ | `focused_crawl` | Crawl a site, rank pages by relevance to a query (Shark-Search / OPIC / BFS) |
30
+ | `fetch_markdown` | One page → clean Markdown (5–10× fewer tokens than raw HTML) |
31
+ | `extract` | Structured records via CSS selectors |
32
+ | `fetch_json_api` | Hit a hidden JSON API |
33
+
34
+ The hosted server is static-only, rate-limited per IP, caps crawls at 10 pages,
35
+ and refuses non-public URLs (SSRF guard). For heavy use or JS-rendered sites,
36
+ run it locally:
37
+
38
+ ```bash
39
+ pip install bytecrawl[mcp]
40
+ claude mcp add bytecrawl -- bytecrawl-mcp # full power, on your machine
41
+ pip install bytecrawl[browser] && playwright install chromium # + JS rendering
42
+ ```
43
+
44
+ ## Why focused crawling?
45
+
46
+ Most crawlers visit pages in whatever order they find them. With a limited
47
+ request budget, order is everything — Shark-Search chases the branches that
48
+ smell like your query and lets the rest decay, so 100 requests get you the 100
49
+ *most useful* pages, not the 100 closest to the seed.
50
+
51
+ ```python
52
+ from bytecrawl import SharkSearch
53
+
54
+ result = SharkSearch(query="vector databases").crawl(
55
+ "https://example.com", max_pages=100)
56
+
57
+ for page in result.top(10):
58
+ print(f'{page["relevance"]:.3f} {page["url"]}')
59
+ ```
60
+
61
+ - **BFS** — level by level, closest to the seed first.
62
+ - **Shark-Search** (Hersovici et al., 1998) — topical best-first; links inherit
63
+ their parent's relevance with decay.
64
+ - **OPIC** (Abiteboul et al., 2003) — live PageRank via "cash" flow, no full
65
+ graph needed (a `pagerank()` implementation is included to compare against).
66
+
67
+ Versus the alternatives: Scrapy is a framework you wire up yourself, Firecrawl
68
+ is a paid SaaS — ByteCrawl is a plain library with a 3-package core and these
69
+ frontier strategies built in.
70
+
71
+ ## Library API
72
+
73
+ ```python
74
+ from bytecrawl import Scraper
75
+
76
+ bot = Scraper()
77
+ page = bot.fetch("https://books.toscrape.com") # auto: static, browser fallback
78
+ books = page.extract("article.product_pod",
79
+ {"title": "h3 a::attr(title)", "price": "p.price_color::text"})
80
+ page.markdown() # clean Markdown for LLMs · page.tokens() # token estimate
81
+ ```
82
+
83
+ ```python
84
+ bot.static(url) # plain HTML
85
+ bot.api(url, params={...}) # hidden JSON API
86
+ bot.browser(url, wait="div.results") # JS via Playwright
87
+ bot.crawl(url, item="article", fields={...},
88
+ next_page="li.next a::attr(href)") # pagination
89
+ bot.session().login(url, data, csrf_field="csrf_token") # authenticated
90
+ ```
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ pip install bytecrawl # slim core (requests + beautifulsoup4 + lxml)
96
+ pip install bytecrawl[llm] # + Markdown for LLMs
97
+ pip install bytecrawl[browser] # + Playwright
98
+ pip install bytecrawl[mcp] # + local MCP server
99
+ pip install bytecrawl[all]
100
+ ```
101
+
102
+ ## Learn each scraping technique
103
+
104
+ A guided walkthrough with a runnable example against a practice site:
105
+ [static HTML](docs/01-html-estatico.md) ·
106
+ [dynamic JS](docs/02-js-dinamico.md) ·
107
+ [hidden APIs](docs/03-api-oculta.md) ·
108
+ [pagination](docs/04-crawling-paginacion.md) ·
109
+ [login](docs/05-login-sesion.md) ·
110
+ [graph crawling](docs/06-crawling-grafos.md) ·
111
+ [Markdown for LLMs](docs/markdown-llms.md) ·
112
+ [ethics](docs/nota-etica.md)
113
+
114
+ ## Contributing
115
+
116
+ ```bash
117
+ pip install -e ".[llm,dev,mcp]"
118
+ pytest # 109 tests, no network required
119
+ pytest -m live # + live browser tests (needs the browser extra)
120
+ ruff check bytecrawl tests
121
+ ```
122
+
123
+ Scrape responsibly: respect `robots.txt`, terms of service and rate limits.
124
+ ByteCrawl ships with a configurable delay between requests.
125
+
126
+ ## License
127
+
128
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,32 @@
1
+ """
2
+ ByteCrawl — Universal scraping layer
3
+ ===================================
4
+ A single API to scrape any site: static HTML, dynamic JS, hidden APIs,
5
+ session login, crawling at scale and Markdown conversion for LLMs.
6
+
7
+ Quickstart:
8
+
9
+ from bytecrawl import Scraper
10
+
11
+ bot = Scraper()
12
+ page = bot.fetch("https://books.toscrape.com")
13
+ books = page.extract("article.product_pod", {
14
+ "title": "h3 a::attr(title)",
15
+ "price": "p.price_color::text",
16
+ })
17
+
18
+ Explicit strategies: bot.static(url) · bot.api(url) · bot.browser(url)
19
+ Crawling: bot.crawl(url, item=..., fields=..., next_page=...)
20
+ Graph crawling: SharkSearch(query=...).crawl(url) · BFS · OPIC
21
+ LLM: page.markdown() · page.tokens()
22
+ """
23
+
24
+ from .core import Page, Scraper, Session
25
+ from .crawler import BFS, OPIC, Crawler, CrawlResult, SharkSearch, cosine, pagerank
26
+
27
+ __all__ = [
28
+ "Scraper", "Page", "Session",
29
+ "Crawler", "BFS", "SharkSearch", "OPIC", "CrawlResult",
30
+ "pagerank", "cosine",
31
+ ]
32
+ __version__ = "1.0.0"