better-websearch-cli 0.0.1__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.
Files changed (41) hide show
  1. better_websearch_cli-0.0.1/LICENSE +21 -0
  2. better_websearch_cli-0.0.1/PKG-INFO +148 -0
  3. better_websearch_cli-0.0.1/README.md +128 -0
  4. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/PKG-INFO +148 -0
  5. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/SOURCES.txt +39 -0
  6. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/dependency_links.txt +1 -0
  7. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/entry_points.txt +2 -0
  8. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/requires.txt +13 -0
  9. better_websearch_cli-0.0.1/better_websearch_cli.egg-info/top_level.txt +1 -0
  10. better_websearch_cli-0.0.1/pyproject.toml +47 -0
  11. better_websearch_cli-0.0.1/setup.cfg +4 -0
  12. better_websearch_cli-0.0.1/tests/test_cache.py +555 -0
  13. better_websearch_cli-0.0.1/tests/test_converter.py +263 -0
  14. better_websearch_cli-0.0.1/tests/test_fetcher.py +186 -0
  15. better_websearch_cli-0.0.1/tests/test_maybe.py +336 -0
  16. better_websearch_cli-0.0.1/tests/test_result.py +371 -0
  17. better_websearch_cli-0.0.1/tests/test_search.py +124 -0
  18. better_websearch_cli-0.0.1/websearch/__main__.py +3 -0
  19. better_websearch_cli-0.0.1/websearch/core/__init__.py +0 -0
  20. better_websearch_cli-0.0.1/websearch/core/cache/__init__.py +5 -0
  21. better_websearch_cli-0.0.1/websearch/core/cache/cache.py +254 -0
  22. better_websearch_cli-0.0.1/websearch/core/cache/key.py +99 -0
  23. better_websearch_cli-0.0.1/websearch/core/cache/storage.py +202 -0
  24. better_websearch_cli-0.0.1/websearch/core/cache/ttl.py +73 -0
  25. better_websearch_cli-0.0.1/websearch/core/converter/__init__.py +5 -0
  26. better_websearch_cli-0.0.1/websearch/core/converter/converter.py +104 -0
  27. better_websearch_cli-0.0.1/websearch/core/converter/encoding.py +20 -0
  28. better_websearch_cli-0.0.1/websearch/core/converter/security.py +30 -0
  29. better_websearch_cli-0.0.1/websearch/core/fetcher/__init__.py +41 -0
  30. better_websearch_cli-0.0.1/websearch/core/fetcher/backoff.py +24 -0
  31. better_websearch_cli-0.0.1/websearch/core/fetcher/detection.py +52 -0
  32. better_websearch_cli-0.0.1/websearch/core/fetcher/errors.py +100 -0
  33. better_websearch_cli-0.0.1/websearch/core/fetcher/fetcher.py +222 -0
  34. better_websearch_cli-0.0.1/websearch/core/search/__init__.py +23 -0
  35. better_websearch_cli-0.0.1/websearch/core/search/client.py +164 -0
  36. better_websearch_cli-0.0.1/websearch/core/search/search.py +196 -0
  37. better_websearch_cli-0.0.1/websearch/core/search/types.py +50 -0
  38. better_websearch_cli-0.0.1/websearch/core/types/__init__.py +0 -0
  39. better_websearch_cli-0.0.1/websearch/core/types/maybe.py +185 -0
  40. better_websearch_cli-0.0.1/websearch/core/types/result.py +209 -0
  41. better_websearch_cli-0.0.1/websearch/main.py +174 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Websearch CLI
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,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: better-websearch-cli
3
+ Version: 0.0.1
4
+ Summary: CLI tool to fetch URLs and search the web
5
+ Requires-Python: >=3.14
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: typer[all]>=0.12
9
+ Requires-Dist: httpx>=0.25
10
+ Requires-Dist: selectolax>=0.3
11
+ Requires-Dist: markdownify>=0.12
12
+ Requires-Dist: rich>=13.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest; extra == "dev"
15
+ Requires-Dist: ruff; extra == "dev"
16
+ Requires-Dist: mypy; extra == "dev"
17
+ Provides-Extra: spa
18
+ Requires-Dist: playwright>=1.40; extra == "spa"
19
+ Dynamic: license-file
20
+
21
+ <p align="center">
22
+ <picture>
23
+ <source media="(prefers-color-scheme: dark)" srcset="public/banner.jpg">
24
+ <source media="(prefers-color-scheme: light)" srcset="public/banner.jpg">
25
+ <img src="public/banner.jpg" alt="Websearch CLI Logo" width="100%">
26
+ </picture>
27
+ </p>
28
+
29
+ <h1 align="center">Websearch CLI</h1>
30
+
31
+ <p align="center">
32
+ Fetch URLs and search the web from your terminal. Fast, simple, and extensible.
33
+ </p>
34
+
35
+ <p align="center">
36
+ <a href="https://pypi.org/project/websearch/">
37
+ <img src="https://img.shields.io/pypi/v/websearch" alt="PyPI Version">
38
+ </a>
39
+ <a href="https://github.com/AliiiBenn/websearch">
40
+ <img src="https://img.shields.io/github/license/AliiiBenn/websearch" alt="License">
41
+ </a>
42
+ <a href="https://github.com/AliiiBenn/websearch/actions">
43
+ <img src="https://img.shields.io/github/actions/workflow/status/AliiiBenn/websearch/test" alt="Tests">
44
+ </a>
45
+ <a href="https://www.python.org/">
46
+ <img src="https://img.shields.io/badge/python-3.14+-blue" alt="Python">
47
+ </a>
48
+ </p>
49
+
50
+ Fetch web pages and search the internet - all from your command line.
51
+
52
+ ## Why Websearch CLI?
53
+
54
+ - **Fast** - Async HTTP powered by httpx
55
+ - **Smart caching** - Local cache with TTL and automatic eviction
56
+ - **Clean output** - HTML to Markdown conversion with XSS protection
57
+ - **Type-safe** - 100% type-annotated Python
58
+
59
+ ## Features
60
+
61
+ - Fetch URLs and convert to Markdown
62
+ - Web search via Brave Search API
63
+ - Local caching with TTL and size limits
64
+ - XSS protection and HTML sanitization
65
+ - SPA (Single Page App) detection
66
+ - Retry with exponential backoff
67
+
68
+ ## Quick Start
69
+
70
+ ```bash
71
+ # Install
72
+ uv add websearch
73
+
74
+ # Fetch a URL as Markdown
75
+ websearch fetch https://example.com
76
+
77
+ # Search the web
78
+ websearch search "python async tutorial"
79
+
80
+ # Fetch with options
81
+ websearch fetch https://example.com --no-cache --verbose
82
+ websearch search "python" -n 20 -t news
83
+ ```
84
+
85
+ ## Command Overview
86
+
87
+ | Command | Description |
88
+ |---------|-------------|
89
+ | `websearch fetch <url>` | Fetch URL and convert to Markdown |
90
+ | `websearch search <query>` | Search the web |
91
+ | `websearch ping` | Check if CLI is working |
92
+
93
+ ## Fetch Options
94
+
95
+ ```
96
+ --refresh, -r Skip cache and force fresh fetch
97
+ --no-cache Disable caching
98
+ --no-verify Skip SSL certificate verification
99
+ --output, -o PATH Output file path
100
+ --verbose, -v Show verbose output
101
+ ```
102
+
103
+ ## Search Options
104
+
105
+ ```
106
+ --count, -n <n> Number of results (1-50, default: 10)
107
+ --type, -t <type> Result type: web, news, images, videos
108
+ --output, -o PATH Output file path
109
+ --json Output raw JSON response
110
+ --no-cache Disable caching
111
+ ```
112
+
113
+ ## Configuration
114
+
115
+ Set your Brave API key:
116
+
117
+ ```bash
118
+ export BRAVE_API_KEY=your_api_key_here
119
+ ```
120
+
121
+ Get your API key at https://brave.com/search/api/
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ # Clone and install
127
+ git clone https://github.com/AliiiBenn/websearch.git
128
+ cd websearch
129
+ uv sync --dev
130
+
131
+ # Run tests
132
+ uv run pytest
133
+
134
+ # Lint and type-check
135
+ uv run ruff check websearch/
136
+ uv run mypy websearch/
137
+
138
+ # Try it out
139
+ uv run websearch fetch https://example.com
140
+ ```
141
+
142
+ ## Contributing
143
+
144
+ Contributions are welcome! Feel free to open issues or submit PRs.
145
+
146
+ ## License
147
+
148
+ MIT - See [LICENSE](LICENSE) for details.
@@ -0,0 +1,128 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="public/banner.jpg">
4
+ <source media="(prefers-color-scheme: light)" srcset="public/banner.jpg">
5
+ <img src="public/banner.jpg" alt="Websearch CLI Logo" width="100%">
6
+ </picture>
7
+ </p>
8
+
9
+ <h1 align="center">Websearch CLI</h1>
10
+
11
+ <p align="center">
12
+ Fetch URLs and search the web from your terminal. Fast, simple, and extensible.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://pypi.org/project/websearch/">
17
+ <img src="https://img.shields.io/pypi/v/websearch" alt="PyPI Version">
18
+ </a>
19
+ <a href="https://github.com/AliiiBenn/websearch">
20
+ <img src="https://img.shields.io/github/license/AliiiBenn/websearch" alt="License">
21
+ </a>
22
+ <a href="https://github.com/AliiiBenn/websearch/actions">
23
+ <img src="https://img.shields.io/github/actions/workflow/status/AliiiBenn/websearch/test" alt="Tests">
24
+ </a>
25
+ <a href="https://www.python.org/">
26
+ <img src="https://img.shields.io/badge/python-3.14+-blue" alt="Python">
27
+ </a>
28
+ </p>
29
+
30
+ Fetch web pages and search the internet - all from your command line.
31
+
32
+ ## Why Websearch CLI?
33
+
34
+ - **Fast** - Async HTTP powered by httpx
35
+ - **Smart caching** - Local cache with TTL and automatic eviction
36
+ - **Clean output** - HTML to Markdown conversion with XSS protection
37
+ - **Type-safe** - 100% type-annotated Python
38
+
39
+ ## Features
40
+
41
+ - Fetch URLs and convert to Markdown
42
+ - Web search via Brave Search API
43
+ - Local caching with TTL and size limits
44
+ - XSS protection and HTML sanitization
45
+ - SPA (Single Page App) detection
46
+ - Retry with exponential backoff
47
+
48
+ ## Quick Start
49
+
50
+ ```bash
51
+ # Install
52
+ uv add websearch
53
+
54
+ # Fetch a URL as Markdown
55
+ websearch fetch https://example.com
56
+
57
+ # Search the web
58
+ websearch search "python async tutorial"
59
+
60
+ # Fetch with options
61
+ websearch fetch https://example.com --no-cache --verbose
62
+ websearch search "python" -n 20 -t news
63
+ ```
64
+
65
+ ## Command Overview
66
+
67
+ | Command | Description |
68
+ |---------|-------------|
69
+ | `websearch fetch <url>` | Fetch URL and convert to Markdown |
70
+ | `websearch search <query>` | Search the web |
71
+ | `websearch ping` | Check if CLI is working |
72
+
73
+ ## Fetch Options
74
+
75
+ ```
76
+ --refresh, -r Skip cache and force fresh fetch
77
+ --no-cache Disable caching
78
+ --no-verify Skip SSL certificate verification
79
+ --output, -o PATH Output file path
80
+ --verbose, -v Show verbose output
81
+ ```
82
+
83
+ ## Search Options
84
+
85
+ ```
86
+ --count, -n <n> Number of results (1-50, default: 10)
87
+ --type, -t <type> Result type: web, news, images, videos
88
+ --output, -o PATH Output file path
89
+ --json Output raw JSON response
90
+ --no-cache Disable caching
91
+ ```
92
+
93
+ ## Configuration
94
+
95
+ Set your Brave API key:
96
+
97
+ ```bash
98
+ export BRAVE_API_KEY=your_api_key_here
99
+ ```
100
+
101
+ Get your API key at https://brave.com/search/api/
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ # Clone and install
107
+ git clone https://github.com/AliiiBenn/websearch.git
108
+ cd websearch
109
+ uv sync --dev
110
+
111
+ # Run tests
112
+ uv run pytest
113
+
114
+ # Lint and type-check
115
+ uv run ruff check websearch/
116
+ uv run mypy websearch/
117
+
118
+ # Try it out
119
+ uv run websearch fetch https://example.com
120
+ ```
121
+
122
+ ## Contributing
123
+
124
+ Contributions are welcome! Feel free to open issues or submit PRs.
125
+
126
+ ## License
127
+
128
+ MIT - See [LICENSE](LICENSE) for details.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: better-websearch-cli
3
+ Version: 0.0.1
4
+ Summary: CLI tool to fetch URLs and search the web
5
+ Requires-Python: >=3.14
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: typer[all]>=0.12
9
+ Requires-Dist: httpx>=0.25
10
+ Requires-Dist: selectolax>=0.3
11
+ Requires-Dist: markdownify>=0.12
12
+ Requires-Dist: rich>=13.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest; extra == "dev"
15
+ Requires-Dist: ruff; extra == "dev"
16
+ Requires-Dist: mypy; extra == "dev"
17
+ Provides-Extra: spa
18
+ Requires-Dist: playwright>=1.40; extra == "spa"
19
+ Dynamic: license-file
20
+
21
+ <p align="center">
22
+ <picture>
23
+ <source media="(prefers-color-scheme: dark)" srcset="public/banner.jpg">
24
+ <source media="(prefers-color-scheme: light)" srcset="public/banner.jpg">
25
+ <img src="public/banner.jpg" alt="Websearch CLI Logo" width="100%">
26
+ </picture>
27
+ </p>
28
+
29
+ <h1 align="center">Websearch CLI</h1>
30
+
31
+ <p align="center">
32
+ Fetch URLs and search the web from your terminal. Fast, simple, and extensible.
33
+ </p>
34
+
35
+ <p align="center">
36
+ <a href="https://pypi.org/project/websearch/">
37
+ <img src="https://img.shields.io/pypi/v/websearch" alt="PyPI Version">
38
+ </a>
39
+ <a href="https://github.com/AliiiBenn/websearch">
40
+ <img src="https://img.shields.io/github/license/AliiiBenn/websearch" alt="License">
41
+ </a>
42
+ <a href="https://github.com/AliiiBenn/websearch/actions">
43
+ <img src="https://img.shields.io/github/actions/workflow/status/AliiiBenn/websearch/test" alt="Tests">
44
+ </a>
45
+ <a href="https://www.python.org/">
46
+ <img src="https://img.shields.io/badge/python-3.14+-blue" alt="Python">
47
+ </a>
48
+ </p>
49
+
50
+ Fetch web pages and search the internet - all from your command line.
51
+
52
+ ## Why Websearch CLI?
53
+
54
+ - **Fast** - Async HTTP powered by httpx
55
+ - **Smart caching** - Local cache with TTL and automatic eviction
56
+ - **Clean output** - HTML to Markdown conversion with XSS protection
57
+ - **Type-safe** - 100% type-annotated Python
58
+
59
+ ## Features
60
+
61
+ - Fetch URLs and convert to Markdown
62
+ - Web search via Brave Search API
63
+ - Local caching with TTL and size limits
64
+ - XSS protection and HTML sanitization
65
+ - SPA (Single Page App) detection
66
+ - Retry with exponential backoff
67
+
68
+ ## Quick Start
69
+
70
+ ```bash
71
+ # Install
72
+ uv add websearch
73
+
74
+ # Fetch a URL as Markdown
75
+ websearch fetch https://example.com
76
+
77
+ # Search the web
78
+ websearch search "python async tutorial"
79
+
80
+ # Fetch with options
81
+ websearch fetch https://example.com --no-cache --verbose
82
+ websearch search "python" -n 20 -t news
83
+ ```
84
+
85
+ ## Command Overview
86
+
87
+ | Command | Description |
88
+ |---------|-------------|
89
+ | `websearch fetch <url>` | Fetch URL and convert to Markdown |
90
+ | `websearch search <query>` | Search the web |
91
+ | `websearch ping` | Check if CLI is working |
92
+
93
+ ## Fetch Options
94
+
95
+ ```
96
+ --refresh, -r Skip cache and force fresh fetch
97
+ --no-cache Disable caching
98
+ --no-verify Skip SSL certificate verification
99
+ --output, -o PATH Output file path
100
+ --verbose, -v Show verbose output
101
+ ```
102
+
103
+ ## Search Options
104
+
105
+ ```
106
+ --count, -n <n> Number of results (1-50, default: 10)
107
+ --type, -t <type> Result type: web, news, images, videos
108
+ --output, -o PATH Output file path
109
+ --json Output raw JSON response
110
+ --no-cache Disable caching
111
+ ```
112
+
113
+ ## Configuration
114
+
115
+ Set your Brave API key:
116
+
117
+ ```bash
118
+ export BRAVE_API_KEY=your_api_key_here
119
+ ```
120
+
121
+ Get your API key at https://brave.com/search/api/
122
+
123
+ ## Development
124
+
125
+ ```bash
126
+ # Clone and install
127
+ git clone https://github.com/AliiiBenn/websearch.git
128
+ cd websearch
129
+ uv sync --dev
130
+
131
+ # Run tests
132
+ uv run pytest
133
+
134
+ # Lint and type-check
135
+ uv run ruff check websearch/
136
+ uv run mypy websearch/
137
+
138
+ # Try it out
139
+ uv run websearch fetch https://example.com
140
+ ```
141
+
142
+ ## Contributing
143
+
144
+ Contributions are welcome! Feel free to open issues or submit PRs.
145
+
146
+ ## License
147
+
148
+ MIT - See [LICENSE](LICENSE) for details.
@@ -0,0 +1,39 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ better_websearch_cli.egg-info/PKG-INFO
5
+ better_websearch_cli.egg-info/SOURCES.txt
6
+ better_websearch_cli.egg-info/dependency_links.txt
7
+ better_websearch_cli.egg-info/entry_points.txt
8
+ better_websearch_cli.egg-info/requires.txt
9
+ better_websearch_cli.egg-info/top_level.txt
10
+ tests/test_cache.py
11
+ tests/test_converter.py
12
+ tests/test_fetcher.py
13
+ tests/test_maybe.py
14
+ tests/test_result.py
15
+ tests/test_search.py
16
+ websearch/__main__.py
17
+ websearch/main.py
18
+ websearch/core/__init__.py
19
+ websearch/core/cache/__init__.py
20
+ websearch/core/cache/cache.py
21
+ websearch/core/cache/key.py
22
+ websearch/core/cache/storage.py
23
+ websearch/core/cache/ttl.py
24
+ websearch/core/converter/__init__.py
25
+ websearch/core/converter/converter.py
26
+ websearch/core/converter/encoding.py
27
+ websearch/core/converter/security.py
28
+ websearch/core/fetcher/__init__.py
29
+ websearch/core/fetcher/backoff.py
30
+ websearch/core/fetcher/detection.py
31
+ websearch/core/fetcher/errors.py
32
+ websearch/core/fetcher/fetcher.py
33
+ websearch/core/search/__init__.py
34
+ websearch/core/search/client.py
35
+ websearch/core/search/search.py
36
+ websearch/core/search/types.py
37
+ websearch/core/types/__init__.py
38
+ websearch/core/types/maybe.py
39
+ websearch/core/types/result.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ websearch = websearch.main:main
@@ -0,0 +1,13 @@
1
+ typer[all]>=0.12
2
+ httpx>=0.25
3
+ selectolax>=0.3
4
+ markdownify>=0.12
5
+ rich>=13.0
6
+
7
+ [dev]
8
+ pytest
9
+ ruff
10
+ mypy
11
+
12
+ [spa]
13
+ playwright>=1.40
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "better-websearch-cli"
3
+ version = "0.0.1"
4
+ description = "CLI tool to fetch URLs and search the web"
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ dependencies = [
8
+ "typer[all]>=0.12",
9
+ "httpx>=0.25",
10
+ "selectolax>=0.3",
11
+ "markdownify>=0.12",
12
+ "rich>=13.0",
13
+ ]
14
+
15
+ [project.optional-dependencies]
16
+ dev = ["pytest", "ruff", "mypy"]
17
+ spa = ["playwright>=1.40"]
18
+
19
+ [project.scripts]
20
+ websearch = "websearch.main:main"
21
+
22
+ [tool.uv]
23
+ package = true
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["."]
27
+ include = ["websearch*"]
28
+ exclude = ["public*"]
29
+
30
+ [tool.pytest.ini_options]
31
+ testpaths = ["tests"]
32
+
33
+ [tool.ruff]
34
+ target-version = "py314"
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "N", "W"]
38
+ ignore = ["E501"]
39
+
40
+ [tool.mypy]
41
+ python_version = "3.14"
42
+ warn_return_any = false
43
+ warn_unused_ignores = false
44
+ explicit_package_bases = true
45
+ ignore_missing_imports = true
46
+ ignore_errors = true
47
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+