webscout 6.2__py3-none-any.whl → 6.3__py3-none-any.whl

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.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

webscout/cli.py CHANGED
@@ -1,347 +1,355 @@
1
- import csv
2
- import logging
3
- import os
4
- from concurrent.futures import ThreadPoolExecutor, as_completed
5
- from datetime import datetime
6
- from urllib.parse import unquote
7
- from pathlib import Path
8
- import click
9
- from curl_cffi import requests
10
- import pyreqwest_impersonate as pri
11
- from .webscout_search import WEBS
12
- from .utils import json_dumps, json_loads
13
- from .version import __version__
14
-
15
- # Import rich for panel interface
16
- from rich.panel import Panel
17
- from rich.markdown import Markdown
18
- from rich.console import Console
19
- from rich.table import Table
20
- from rich.style import Style
21
- from rich.text import Text
22
- from rich.align import Align
23
- from rich.progress import track, Progress
24
- from rich.prompt import Prompt, Confirm
25
- from rich.columns import Columns
26
- from pyfiglet import figlet_format
27
-
28
- logger = logging.getLogger(__name__)
29
-
30
- COLORS = {
31
- 0: "black",
32
- 1: "red",
33
- 2: "green",
34
- 3: "yellow",
35
- 4: "blue",
36
- 5: "magenta",
37
- 6: "cyan",
38
- 7: "bright_black",
39
- 8: "bright_red",
40
- 9: "bright_green",
41
- 10: "bright_yellow",
42
- 11: "bright_blue",
43
- 12: "bright_magenta",
44
- 13: "bright_cyan",
45
- 14: "white",
46
- 15: "bright_white",
47
- }
48
-
49
- def _print_data(data):
50
- """Prints data using rich panels and markdown."""
51
- console = Console()
52
- if data:
53
- for i, e in enumerate(data, start=1):
54
- table = Table(show_header=False, show_lines=True, expand=True, box=None) # Removed duplicate title
55
- table.add_column("Key", style="cyan", no_wrap=True, width=15)
56
- table.add_column("Value", style="white")
57
-
58
- for j, (k, v) in enumerate(e.items(), start=1):
59
- if v:
60
- width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
61
- k = "language" if k == "detected_language" else k
62
- text = click.wrap_text(
63
- f"{v}", width=width, initial_indent="", subsequent_indent=" " * 18, preserve_paragraphs=True
64
- ).replace("\n", "\n\n")
65
- else:
66
- text = v
67
- table.add_row(k, text)
68
-
69
- # Only the Panel has the title now
70
- console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
71
- console.print("\n")
72
-
73
-
74
- def _sanitize_keywords(keywords):
75
- """Sanitizes keywords for file names and paths. Removes invalid characters like ':'. """
76
- keywords = (
77
- keywords.replace("filetype", "")
78
- .replace(":", "")
79
- .replace('"', "'")
80
- .replace("site", "")
81
- .replace(" ", "_")
82
- .replace("/", "_")
83
- .replace("\\", "_")
84
- .replace(" ", "")
85
- )
86
- return keywords
87
-
88
- @click.group(chain=True)
89
- def cli():
90
- """webscout CLI tool - Search the web with a rich UI."""
91
- console = Console()
92
- console.print(f"[bold blue]{figlet_format('Webscout')}[/]\n", justify="center")
93
-
94
- def safe_entry_point():
95
- try:
96
- cli()
97
- except Exception as ex:
98
- click.echo(f"{type(ex).__name__}: {ex}")
99
-
100
-
101
- @cli.command()
102
- def version():
103
- """Shows the current version of webscout."""
104
- console = Console()
105
- console.print(Panel(Text(f"webscout v{__version__}", style="cyan"), title="Version", expand=False))
106
-
107
-
108
- @cli.command()
109
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
110
- def chat(proxy):
111
- """Interactive AI chat using DuckDuckGo's AI."""
112
- models = ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"]
113
- client = WEBS(proxy=proxy)
114
-
115
- console = Console()
116
- console.print(Panel(Text("Available AI Models:", style="cyan"), title="DuckDuckGo AI Chat", expand=False))
117
- console.print(Columns([Panel(Text(model, justify="center"), expand=True) for model in models]))
118
- chosen_model_idx = Prompt.ask("[bold cyan]Choose a model by entering its number[/] [1]", choices=[str(i) for i in range(1, len(models) + 1)], default="1")
119
- chosen_model_idx = int(chosen_model_idx) - 1
120
- model = models[chosen_model_idx]
121
- console.print(f"[bold green]Using model:[/] {model}")
122
-
123
- while True:
124
- user_input = Prompt.ask(f"{'-'*78}\n[bold blue]You:[/]")
125
- if not user_input.strip():
126
- break
127
-
128
- resp_answer = client.chat(keywords=user_input, model=model)
129
- text = click.wrap_text(resp_answer, width=78, preserve_paragraphs=True)
130
- console.print(Panel(Text(f"AI: {text}", style="green"), title="AI Response"))
131
-
132
- if "exit" in user_input.lower() or "quit" in user_input.lower():
133
- console.print(Panel(Text("Exiting chat session.", style="cyan"), title="Goodbye", expand=False))
134
- break
135
-
136
-
137
- @cli.command()
138
- @click.option("-k", "--keywords", required=True, help="Keywords for text search.")
139
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
140
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
141
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
142
- @click.option("-m", "--max_results", default=20, help="Maximum number of results to retrieve (default: 20).")
143
- @click.option("-b", "--backend", default="api", type=click.Choice(["api", "html", "lite"]), help="Backend to use (api, html, lite).")
144
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
145
- def text(keywords, region, safesearch, timelimit, backend, max_results, proxy):
146
- """Performs a text search using DuckDuckGo API with a rich UI."""
147
- data = WEBS(proxy=proxy).text(
148
- keywords=keywords,
149
- region=region,
150
- safesearch=safesearch,
151
- timelimit=timelimit,
152
- backend=backend,
153
- max_results=max_results,
154
- )
155
- _print_data(data)
156
-
157
- @cli.command()
158
- @click.option("-k", "--keywords", required=True, help="Keywords for answers search.")
159
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
160
- def answers(keywords, proxy):
161
- """Performs an answers search using DuckDuckGo API with a rich UI."""
162
- data = WEBS(proxy=proxy).answers(keywords=keywords)
163
- _print_data(data)
164
-
165
-
166
- @cli.command()
167
- @click.option("-k", "--keywords", required=True, help="Keywords for images search.")
168
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
169
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
170
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["Day", "Week", "Month", "Year"]), help="Time limit (Day, Week, Month, Year).")
171
- @click.option("-size", "--size", default=None, type=click.Choice(["Small", "Medium", "Large", "Wallpaper"]), help="Image size (Small, Medium, Large, Wallpaper).")
172
- @click.option(
173
- "-c",
174
- "--color",
175
- default=None,
176
- type=click.Choice(
177
- [
178
- "color",
179
- "Monochrome",
180
- "Red",
181
- "Orange",
182
- "Yellow",
183
- "Green",
184
- "Blue",
185
- "Purple",
186
- "Pink",
187
- "Brown",
188
- "Black",
189
- "Gray",
190
- "Teal",
191
- "White",
192
- ]
193
- ),
194
- help="Image color (color, Monochrome, Red, Orange, Yellow, Green, Blue, Purple, Pink, Brown, Black, Gray, Teal, White).",
195
- )
196
- @click.option(
197
- "-type", "--type_image", default=None, type=click.Choice(["photo", "clipart", "gif", "transparent", "line"]), help="Image type (photo, clipart, gif, transparent, line)."
198
- )
199
- @click.option("-l", "--layout", default=None, type=click.Choice(["Square", "Tall", "Wide"]), help="Image layout (Square, Tall, Wide).")
200
- @click.option(
201
- "-lic",
202
- "--license_image",
203
- default=None,
204
- type=click.Choice(["any", "Public", "Share", "Modify", "ModifyCommercially"]),
205
- help="Image license (any, Public, Share, Modify, ModifyCommercially).",
206
- )
207
- @click.option("-m", "--max_results", default=90, help="Maximum number of results to retrieve (default: 90).")
208
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
209
- def images(
210
- keywords,
211
- region,
212
- safesearch,
213
- timelimit,
214
- size,
215
- color,
216
- type_image,
217
- layout,
218
- license_image,
219
- max_results,
220
- proxy,
221
- ):
222
- """Performs an images search using DuckDuckGo API with a rich UI."""
223
- data = WEBS(proxy=proxy).images(
224
- keywords=keywords,
225
- region=region,
226
- safesearch=safesearch,
227
- timelimit=timelimit,
228
- size=size,
229
- color=color,
230
- type_image=type_image,
231
- layout=layout,
232
- license_image=license_image,
233
- max_results=max_results,
234
- )
235
- _print_data(data)
236
-
237
-
238
- @cli.command()
239
- @click.option("-k", "--keywords", required=True, help="Keywords for videos search.")
240
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
241
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
242
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m"]), help="Time limit (d: day, w: week, m: month).")
243
- @click.option("-res", "--resolution", default=None, type=click.Choice(["high", "standart"]), help="Video resolution (high, standart).")
244
- @click.option("-d", "--duration", default=None, type=click.Choice(["short", "medium", "long"]), help="Video duration (short, medium, long).")
245
- @click.option("-lic", "--license_videos", default=None, type=click.Choice(["creativeCommon", "youtube"]), help="Video license (creativeCommon, youtube).")
246
- @click.option("-m", "--max_results", default=50, help="Maximum number of results to retrieve (default: 50).")
247
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
248
- def videos(keywords, region, safesearch, timelimit, resolution, duration, license_videos, max_results, proxy):
249
- """Performs a videos search using DuckDuckGo API with a rich UI."""
250
- data = WEBS(proxy=proxy).videos(
251
- keywords=keywords,
252
- region=region,
253
- safesearch=safesearch,
254
- timelimit=timelimit,
255
- resolution=resolution,
256
- duration=duration,
257
- license_videos=license_videos,
258
- max_results=max_results,
259
- )
260
- _print_data(data)
261
-
262
-
263
- @cli.command()
264
- @click.option("-k", "--keywords", required=True, help="Keywords for news search.")
265
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
266
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
267
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
268
- @click.option("-m", "--max_results", default=25, help="Maximum number of results to retrieve (default: 25).")
269
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
270
- def news(keywords, region, safesearch, timelimit, max_results, proxy):
271
- """Performs a news search using DuckDuckGo API with a rich UI."""
272
- data = WEBS(proxy=proxy).news(
273
- keywords=keywords, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results
274
- )
275
- _print_data(data)
276
-
277
-
278
- @cli.command()
279
- @click.option("-k", "--keywords", required=True, help="Keywords for maps search.")
280
- @click.option("-p", "--place", default=None, help="Simplified search - if set, the other parameters are not used.")
281
- @click.option("-s", "--street", default=None, help="House number/street.")
282
- @click.option("-c", "--city", default=None, help="City of search.")
283
- @click.option("-county", "--county", default=None, help="County of search.")
284
- @click.option("-state", "--state", default=None, help="State of search.")
285
- @click.option("-country", "--country", default=None, help="Country of search.")
286
- @click.option("-post", "--postalcode", default=None, help="Postal code of search.")
287
- @click.option("-lat", "--latitude", default=None, help="Geographic coordinate (north-south position).")
288
- @click.option("-lon", "--longitude", default=None, help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used.")
289
- @click.option("-r", "--radius", default=0, help="Expand the search square by the distance in kilometers.")
290
- @click.option("-m", "--max_results", default=50, help="Number of results (default: 50).")
291
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
292
- def maps(
293
- keywords,
294
- place,
295
- street,
296
- city,
297
- county,
298
- state,
299
- country,
300
- postalcode,
301
- latitude,
302
- longitude,
303
- radius,
304
- max_results,
305
- proxy,
306
- ):
307
- """Performs a maps search using DuckDuckGo API with a rich UI."""
308
- data = WEBS(proxy=proxy).maps(
309
- keywords=keywords,
310
- place=place,
311
- street=street,
312
- city=city,
313
- county=county,
314
- state=state,
315
- country=country,
316
- postalcode=postalcode,
317
- latitude=latitude,
318
- longitude=longitude,
319
- radius=radius,
320
- max_results=max_results,
321
- )
322
- _print_data(data)
323
-
324
-
325
- @cli.command()
326
- @click.option("-k", "--keywords", required=True, help="Text for translation.")
327
- @click.option("-f", "--from_", help="Language to translate from (defaults automatically).")
328
- @click.option("-t", "--to", default="en", help="Language to translate to (default: 'en').")
329
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
330
- def translate(keywords, from_, to, proxy):
331
- """Performs translation using DuckDuckGo API with a rich UI."""
332
- data = WEBS(proxy=proxy).translate(keywords=keywords, from_=from_, to=to)
333
- _print_data(data)
334
-
335
-
336
- @cli.command()
337
- @click.option("-k", "--keywords", required=True, help="Keywords for query.")
338
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
339
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
340
- def suggestions(keywords, region, proxy):
341
- """Performs a suggestions search using DuckDuckGo API with a rich UI."""
342
- data = WEBS(proxy=proxy).suggestions(keywords=keywords, region=region)
343
- _print_data(data)
344
-
345
-
346
- if __name__ == "__main__":
1
+ import csv
2
+ import logging
3
+ import os
4
+ from concurrent.futures import ThreadPoolExecutor, as_completed
5
+ from datetime import datetime
6
+ from urllib.parse import unquote
7
+ from pathlib import Path
8
+ import click
9
+ from curl_cffi import requests
10
+ import pyreqwest_impersonate as pri
11
+ from .webscout_search import WEBS
12
+ from .utils import json_dumps, json_loads
13
+ from .version import __version__
14
+ from .interactive import interactive_session
15
+
16
+ # Import rich for panel interface
17
+ from rich.panel import Panel
18
+ from rich.markdown import Markdown
19
+ from rich.console import Console
20
+ from rich.table import Table
21
+ from rich.style import Style
22
+ from rich.text import Text
23
+ from rich.align import Align
24
+ from rich.progress import track, Progress
25
+ from rich.prompt import Prompt, Confirm
26
+ from rich.columns import Columns
27
+ from pyfiglet import figlet_format
28
+
29
+ logger = logging.getLogger(__name__)
30
+
31
+ COLORS = {
32
+ 0: "black",
33
+ 1: "red",
34
+ 2: "green",
35
+ 3: "yellow",
36
+ 4: "blue",
37
+ 5: "magenta",
38
+ 6: "cyan",
39
+ 7: "bright_black",
40
+ 8: "bright_red",
41
+ 9: "bright_green",
42
+ 10: "bright_yellow",
43
+ 11: "bright_blue",
44
+ 12: "bright_magenta",
45
+ 13: "bright_cyan",
46
+ 14: "white",
47
+ 15: "bright_white",
48
+ }
49
+
50
+ def _print_data(data):
51
+ """Prints data using rich panels and markdown."""
52
+ console = Console()
53
+ if data:
54
+ for i, e in enumerate(data, start=1):
55
+ table = Table(show_header=False, show_lines=True, expand=True, box=None) # Removed duplicate title
56
+ table.add_column("Key", style="cyan", no_wrap=True, width=15)
57
+ table.add_column("Value", style="white")
58
+
59
+ for j, (k, v) in enumerate(e.items(), start=1):
60
+ if v:
61
+ width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
62
+ k = "language" if k == "detected_language" else k
63
+ text = click.wrap_text(
64
+ f"{v}", width=width, initial_indent="", subsequent_indent=" " * 18, preserve_paragraphs=True
65
+ ).replace("\n", "\n\n")
66
+ else:
67
+ text = v
68
+ table.add_row(k, text)
69
+
70
+ # Only the Panel has the title now
71
+ console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
72
+ console.print("\n")
73
+
74
+
75
+ def _sanitize_keywords(keywords):
76
+ """Sanitizes keywords for file names and paths. Removes invalid characters like ':'. """
77
+ keywords = (
78
+ keywords.replace("filetype", "")
79
+ .replace(":", "")
80
+ .replace('"', "'")
81
+ .replace("site", "")
82
+ .replace(" ", "_")
83
+ .replace("/", "_")
84
+ .replace("\\", "_")
85
+ .replace(" ", "")
86
+ )
87
+ return keywords
88
+
89
+ @click.group(chain=True)
90
+ def cli():
91
+ """webscout CLI tool - Search the web with a rich UI."""
92
+ console = Console()
93
+ console.print(f"[bold blue]{figlet_format('Webscout')}[/]\n", justify="center")
94
+
95
+ def safe_entry_point():
96
+ try:
97
+ cli()
98
+ except Exception as ex:
99
+ click.echo(f"{type(ex).__name__}: {ex}")
100
+
101
+
102
+ @cli.command()
103
+ def version():
104
+ """Shows the current version of webscout."""
105
+ console = Console()
106
+ console.print(Panel(Text(f"webscout v{__version__}", style="cyan"), title="Version", expand=False))
107
+
108
+
109
+ @cli.command()
110
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
111
+ def chat(proxy):
112
+ """Interactive AI chat using DuckDuckGo's AI."""
113
+ models = ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"]
114
+ client = WEBS(proxy=proxy)
115
+
116
+ console = Console()
117
+ console.print(Panel(Text("Available AI Models:", style="cyan"), title="DuckDuckGo AI Chat", expand=False))
118
+ console.print(Columns([Panel(Text(model, justify="center"), expand=True) for model in models]))
119
+ chosen_model_idx = Prompt.ask("[bold cyan]Choose a model by entering its number[/] [1]", choices=[str(i) for i in range(1, len(models) + 1)], default="1")
120
+ chosen_model_idx = int(chosen_model_idx) - 1
121
+ model = models[chosen_model_idx]
122
+ console.print(f"[bold green]Using model:[/] {model}")
123
+
124
+ while True:
125
+ user_input = Prompt.ask(f"{'-'*78}\n[bold blue]You:[/]")
126
+ if not user_input.strip():
127
+ break
128
+
129
+ resp_answer = client.chat(keywords=user_input, model=model)
130
+ text = click.wrap_text(resp_answer, width=78, preserve_paragraphs=True)
131
+ console.print(Panel(Text(f"AI: {text}", style="green"), title="AI Response"))
132
+
133
+ if "exit" in user_input.lower() or "quit" in user_input.lower():
134
+ console.print(Panel(Text("Exiting chat session.", style="cyan"), title="Goodbye", expand=False))
135
+ break
136
+
137
+
138
+ @cli.command()
139
+ @click.option("-k", "--keywords", required=True, help="Keywords for text search.")
140
+ @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
141
+ @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
142
+ @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
143
+ @click.option("-m", "--max_results", default=20, help="Maximum number of results to retrieve (default: 20).")
144
+ @click.option("-b", "--backend", default="api", type=click.Choice(["api", "html", "lite"]), help="Backend to use (api, html, lite).")
145
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
146
+ def text(keywords, region, safesearch, timelimit, backend, max_results, proxy):
147
+ """Performs a text search using DuckDuckGo API with a rich UI."""
148
+ data = WEBS(proxy=proxy).text(
149
+ keywords=keywords,
150
+ region=region,
151
+ safesearch=safesearch,
152
+ timelimit=timelimit,
153
+ backend=backend,
154
+ max_results=max_results,
155
+ )
156
+ _print_data(data)
157
+
158
+ @cli.command()
159
+ @click.option("-k", "--keywords", required=True, help="Keywords for answers search.")
160
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
161
+ def answers(keywords, proxy):
162
+ """Performs an answers search using DuckDuckGo API with a rich UI."""
163
+ data = WEBS(proxy=proxy).answers(keywords=keywords)
164
+ _print_data(data)
165
+
166
+
167
+ @cli.command()
168
+ @click.option("-k", "--keywords", required=True, help="Keywords for images search.")
169
+ @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
170
+ @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
171
+ @click.option("-t", "--timelimit", default=None, type=click.Choice(["Day", "Week", "Month", "Year"]), help="Time limit (Day, Week, Month, Year).")
172
+ @click.option("-size", "--size", default=None, type=click.Choice(["Small", "Medium", "Large", "Wallpaper"]), help="Image size (Small, Medium, Large, Wallpaper).")
173
+ @click.option(
174
+ "-c",
175
+ "--color",
176
+ default=None,
177
+ type=click.Choice(
178
+ [
179
+ "color",
180
+ "Monochrome",
181
+ "Red",
182
+ "Orange",
183
+ "Yellow",
184
+ "Green",
185
+ "Blue",
186
+ "Purple",
187
+ "Pink",
188
+ "Brown",
189
+ "Black",
190
+ "Gray",
191
+ "Teal",
192
+ "White",
193
+ ]
194
+ ),
195
+ help="Image color (color, Monochrome, Red, Orange, Yellow, Green, Blue, Purple, Pink, Brown, Black, Gray, Teal, White).",
196
+ )
197
+ @click.option(
198
+ "-type", "--type_image", default=None, type=click.Choice(["photo", "clipart", "gif", "transparent", "line"]), help="Image type (photo, clipart, gif, transparent, line)."
199
+ )
200
+ @click.option("-l", "--layout", default=None, type=click.Choice(["Square", "Tall", "Wide"]), help="Image layout (Square, Tall, Wide).")
201
+ @click.option(
202
+ "-lic",
203
+ "--license_image",
204
+ default=None,
205
+ type=click.Choice(["any", "Public", "Share", "Modify", "ModifyCommercially"]),
206
+ help="Image license (any, Public, Share, Modify, ModifyCommercially).",
207
+ )
208
+ @click.option("-m", "--max_results", default=90, help="Maximum number of results to retrieve (default: 90).")
209
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
210
+ def images(
211
+ keywords,
212
+ region,
213
+ safesearch,
214
+ timelimit,
215
+ size,
216
+ color,
217
+ type_image,
218
+ layout,
219
+ license_image,
220
+ max_results,
221
+ proxy,
222
+ ):
223
+ """Performs an images search using DuckDuckGo API with a rich UI."""
224
+ data = WEBS(proxy=proxy).images(
225
+ keywords=keywords,
226
+ region=region,
227
+ safesearch=safesearch,
228
+ timelimit=timelimit,
229
+ size=size,
230
+ color=color,
231
+ type_image=type_image,
232
+ layout=layout,
233
+ license_image=license_image,
234
+ max_results=max_results,
235
+ )
236
+ _print_data(data)
237
+
238
+
239
+ @cli.command()
240
+ @click.option("-k", "--keywords", required=True, help="Keywords for videos search.")
241
+ @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
242
+ @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
243
+ @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m"]), help="Time limit (d: day, w: week, m: month).")
244
+ @click.option("-res", "--resolution", default=None, type=click.Choice(["high", "standart"]), help="Video resolution (high, standart).")
245
+ @click.option("-d", "--duration", default=None, type=click.Choice(["short", "medium", "long"]), help="Video duration (short, medium, long).")
246
+ @click.option("-lic", "--license_videos", default=None, type=click.Choice(["creativeCommon", "youtube"]), help="Video license (creativeCommon, youtube).")
247
+ @click.option("-m", "--max_results", default=50, help="Maximum number of results to retrieve (default: 50).")
248
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
249
+ def videos(keywords, region, safesearch, timelimit, resolution, duration, license_videos, max_results, proxy):
250
+ """Performs a videos search using DuckDuckGo API with a rich UI."""
251
+ data = WEBS(proxy=proxy).videos(
252
+ keywords=keywords,
253
+ region=region,
254
+ safesearch=safesearch,
255
+ timelimit=timelimit,
256
+ resolution=resolution,
257
+ duration=duration,
258
+ license_videos=license_videos,
259
+ max_results=max_results,
260
+ )
261
+ _print_data(data)
262
+
263
+
264
+ @cli.command()
265
+ @click.option("-k", "--keywords", required=True, help="Keywords for news search.")
266
+ @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
267
+ @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
268
+ @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
269
+ @click.option("-m", "--max_results", default=25, help="Maximum number of results to retrieve (default: 25).")
270
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
271
+ def news(keywords, region, safesearch, timelimit, max_results, proxy):
272
+ """Performs a news search using DuckDuckGo API with a rich UI."""
273
+ data = WEBS(proxy=proxy).news(
274
+ keywords=keywords, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results
275
+ )
276
+ _print_data(data)
277
+
278
+
279
+ @cli.command()
280
+ @click.option("-k", "--keywords", required=True, help="Keywords for maps search.")
281
+ @click.option("-p", "--place", default=None, help="Simplified search - if set, the other parameters are not used.")
282
+ @click.option("-s", "--street", default=None, help="House number/street.")
283
+ @click.option("-c", "--city", default=None, help="City of search.")
284
+ @click.option("-county", "--county", default=None, help="County of search.")
285
+ @click.option("-state", "--state", default=None, help="State of search.")
286
+ @click.option("-country", "--country", default=None, help="Country of search.")
287
+ @click.option("-post", "--postalcode", default=None, help="Postal code of search.")
288
+ @click.option("-lat", "--latitude", default=None, help="Geographic coordinate (north-south position).")
289
+ @click.option("-lon", "--longitude", default=None, help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used.")
290
+ @click.option("-r", "--radius", default=0, help="Expand the search square by the distance in kilometers.")
291
+ @click.option("-m", "--max_results", default=50, help="Number of results (default: 50).")
292
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
293
+ def maps(
294
+ keywords,
295
+ place,
296
+ street,
297
+ city,
298
+ county,
299
+ state,
300
+ country,
301
+ postalcode,
302
+ latitude,
303
+ longitude,
304
+ radius,
305
+ max_results,
306
+ proxy,
307
+ ):
308
+ """Performs a maps search using DuckDuckGo API with a rich UI."""
309
+ data = WEBS(proxy=proxy).maps(
310
+ keywords=keywords,
311
+ place=place,
312
+ street=street,
313
+ city=city,
314
+ county=county,
315
+ state=state,
316
+ country=country,
317
+ postalcode=postalcode,
318
+ latitude=latitude,
319
+ longitude=longitude,
320
+ radius=radius,
321
+ max_results=max_results,
322
+ )
323
+ _print_data(data)
324
+
325
+
326
+ @cli.command()
327
+ @click.option("-k", "--keywords", required=True, help="Text for translation.")
328
+ @click.option("-f", "--from_", help="Language to translate from (defaults automatically).")
329
+ @click.option("-t", "--to", default="en", help="Language to translate to (default: 'en').")
330
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
331
+ def translate(keywords, from_, to, proxy):
332
+ """Performs translation using DuckDuckGo API with a rich UI."""
333
+ data = WEBS(proxy=proxy).translate(keywords=keywords, from_=from_, to=to)
334
+ _print_data(data)
335
+
336
+
337
+ @cli.command()
338
+ @click.option("-k", "--keywords", required=True, help="Keywords for query.")
339
+ @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
340
+ @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
341
+ def suggestions(keywords, region, proxy):
342
+ """Performs a suggestions search using DuckDuckGo API with a rich UI."""
343
+ data = WEBS(proxy=proxy).suggestions(keywords=keywords, region=region)
344
+ _print_data(data)
345
+
346
+
347
+ @cli.command()
348
+ @click.option("--proxy", help="Proxy to use for requests", default=None)
349
+ def interactive(proxy):
350
+ """Start an interactive search session with AI-powered responses."""
351
+ interactive_session()
352
+
353
+
354
+ if __name__ == "__main__":
347
355
  cli(prog_name="WEBS")