webscout 7.1__py3-none-any.whl → 7.2__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.

Files changed (144) hide show
  1. webscout/AIauto.py +191 -191
  2. webscout/AIbase.py +122 -122
  3. webscout/AIutel.py +440 -440
  4. webscout/Bard.py +343 -161
  5. webscout/DWEBS.py +489 -492
  6. webscout/Extra/YTToolkit/YTdownloader.py +995 -995
  7. webscout/Extra/YTToolkit/__init__.py +2 -2
  8. webscout/Extra/YTToolkit/transcriber.py +476 -479
  9. webscout/Extra/YTToolkit/ytapi/channel.py +307 -307
  10. webscout/Extra/YTToolkit/ytapi/playlist.py +58 -58
  11. webscout/Extra/YTToolkit/ytapi/pool.py +7 -7
  12. webscout/Extra/YTToolkit/ytapi/utils.py +62 -62
  13. webscout/Extra/YTToolkit/ytapi/video.py +103 -103
  14. webscout/Extra/autocoder/__init__.py +9 -9
  15. webscout/Extra/autocoder/autocoder_utiles.py +199 -199
  16. webscout/Extra/autocoder/rawdog.py +5 -7
  17. webscout/Extra/autollama.py +230 -230
  18. webscout/Extra/gguf.py +3 -3
  19. webscout/Extra/weather.py +171 -171
  20. webscout/LLM.py +442 -442
  21. webscout/Litlogger/__init__.py +67 -681
  22. webscout/Litlogger/core/__init__.py +6 -0
  23. webscout/Litlogger/core/level.py +20 -0
  24. webscout/Litlogger/core/logger.py +123 -0
  25. webscout/Litlogger/handlers/__init__.py +12 -0
  26. webscout/Litlogger/handlers/console.py +50 -0
  27. webscout/Litlogger/handlers/file.py +143 -0
  28. webscout/Litlogger/handlers/network.py +174 -0
  29. webscout/Litlogger/styles/__init__.py +7 -0
  30. webscout/Litlogger/styles/colors.py +231 -0
  31. webscout/Litlogger/styles/formats.py +377 -0
  32. webscout/Litlogger/styles/text.py +87 -0
  33. webscout/Litlogger/utils/__init__.py +6 -0
  34. webscout/Litlogger/utils/detectors.py +154 -0
  35. webscout/Litlogger/utils/formatters.py +200 -0
  36. webscout/Provider/AISEARCH/DeepFind.py +250 -250
  37. webscout/Provider/Blackboxai.py +3 -3
  38. webscout/Provider/ChatGPTGratis.py +226 -0
  39. webscout/Provider/Cloudflare.py +3 -4
  40. webscout/Provider/DeepSeek.py +218 -0
  41. webscout/Provider/Deepinfra.py +3 -3
  42. webscout/Provider/Free2GPT.py +131 -124
  43. webscout/Provider/Gemini.py +100 -115
  44. webscout/Provider/Glider.py +3 -3
  45. webscout/Provider/Groq.py +5 -1
  46. webscout/Provider/Jadve.py +3 -3
  47. webscout/Provider/Marcus.py +191 -192
  48. webscout/Provider/Netwrck.py +3 -3
  49. webscout/Provider/PI.py +2 -2
  50. webscout/Provider/PizzaGPT.py +2 -3
  51. webscout/Provider/QwenLM.py +311 -0
  52. webscout/Provider/TTI/AiForce/__init__.py +22 -22
  53. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -257
  54. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -242
  55. webscout/Provider/TTI/Nexra/__init__.py +22 -22
  56. webscout/Provider/TTI/Nexra/async_nexra.py +286 -286
  57. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -258
  58. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -23
  59. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -330
  60. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -285
  61. webscout/Provider/TTI/artbit/__init__.py +22 -22
  62. webscout/Provider/TTI/artbit/async_artbit.py +184 -184
  63. webscout/Provider/TTI/artbit/sync_artbit.py +176 -176
  64. webscout/Provider/TTI/blackbox/__init__.py +4 -4
  65. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -212
  66. webscout/Provider/TTI/blackbox/sync_blackbox.py +199 -199
  67. webscout/Provider/TTI/deepinfra/__init__.py +4 -4
  68. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -227
  69. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -199
  70. webscout/Provider/TTI/huggingface/__init__.py +22 -22
  71. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -199
  72. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -195
  73. webscout/Provider/TTI/imgninza/__init__.py +4 -4
  74. webscout/Provider/TTI/imgninza/async_ninza.py +214 -214
  75. webscout/Provider/TTI/imgninza/sync_ninza.py +209 -209
  76. webscout/Provider/TTI/talkai/__init__.py +4 -4
  77. webscout/Provider/TTI/talkai/async_talkai.py +229 -229
  78. webscout/Provider/TTI/talkai/sync_talkai.py +207 -207
  79. webscout/Provider/TTS/deepgram.py +182 -182
  80. webscout/Provider/TTS/elevenlabs.py +136 -136
  81. webscout/Provider/TTS/gesserit.py +150 -150
  82. webscout/Provider/TTS/murfai.py +138 -138
  83. webscout/Provider/TTS/parler.py +133 -134
  84. webscout/Provider/TTS/streamElements.py +360 -360
  85. webscout/Provider/TTS/utils.py +280 -280
  86. webscout/Provider/TTS/voicepod.py +116 -116
  87. webscout/Provider/TextPollinationsAI.py +2 -3
  88. webscout/Provider/WiseCat.py +193 -0
  89. webscout/Provider/__init__.py +144 -134
  90. webscout/Provider/cerebras.py +242 -227
  91. webscout/Provider/chatglm.py +204 -204
  92. webscout/Provider/dgaf.py +2 -3
  93. webscout/Provider/gaurish.py +2 -3
  94. webscout/Provider/geminiapi.py +208 -208
  95. webscout/Provider/granite.py +223 -0
  96. webscout/Provider/hermes.py +218 -218
  97. webscout/Provider/llama3mitril.py +179 -179
  98. webscout/Provider/llamatutor.py +3 -3
  99. webscout/Provider/llmchat.py +2 -3
  100. webscout/Provider/meta.py +794 -794
  101. webscout/Provider/multichat.py +331 -331
  102. webscout/Provider/typegpt.py +359 -359
  103. webscout/Provider/yep.py +2 -2
  104. webscout/__main__.py +5 -5
  105. webscout/cli.py +319 -319
  106. webscout/conversation.py +241 -242
  107. webscout/exceptions.py +328 -328
  108. webscout/litagent/__init__.py +28 -28
  109. webscout/litagent/agent.py +2 -3
  110. webscout/litprinter/__init__.py +0 -58
  111. webscout/scout/__init__.py +8 -8
  112. webscout/scout/core.py +884 -884
  113. webscout/scout/element.py +459 -459
  114. webscout/scout/parsers/__init__.py +69 -69
  115. webscout/scout/parsers/html5lib_parser.py +172 -172
  116. webscout/scout/parsers/html_parser.py +236 -236
  117. webscout/scout/parsers/lxml_parser.py +178 -178
  118. webscout/scout/utils.py +38 -38
  119. webscout/swiftcli/__init__.py +811 -811
  120. webscout/update_checker.py +2 -12
  121. webscout/version.py +1 -1
  122. webscout/webscout_search.py +5 -4
  123. webscout/zeroart/__init__.py +54 -54
  124. webscout/zeroart/base.py +60 -60
  125. webscout/zeroart/effects.py +99 -99
  126. webscout/zeroart/fonts.py +816 -816
  127. {webscout-7.1.dist-info → webscout-7.2.dist-info}/METADATA +4 -3
  128. webscout-7.2.dist-info/RECORD +217 -0
  129. webstoken/__init__.py +30 -30
  130. webstoken/classifier.py +189 -189
  131. webstoken/keywords.py +216 -216
  132. webstoken/language.py +128 -128
  133. webstoken/ner.py +164 -164
  134. webstoken/normalizer.py +35 -35
  135. webstoken/processor.py +77 -77
  136. webstoken/sentiment.py +206 -206
  137. webstoken/stemmer.py +73 -73
  138. webstoken/tagger.py +60 -60
  139. webstoken/tokenizer.py +158 -158
  140. webscout-7.1.dist-info/RECORD +0 -198
  141. {webscout-7.1.dist-info → webscout-7.2.dist-info}/LICENSE.md +0 -0
  142. {webscout-7.1.dist-info → webscout-7.2.dist-info}/WHEEL +0 -0
  143. {webscout-7.1.dist-info → webscout-7.2.dist-info}/entry_points.txt +0 -0
  144. {webscout-7.1.dist-info → webscout-7.2.dist-info}/top_level.txt +0 -0
webscout/cli.py CHANGED
@@ -1,319 +1,319 @@
1
- import os
2
- import sys
3
- from concurrent.futures import ThreadPoolExecutor, as_completed
4
- from datetime import datetime
5
- from urllib.parse import unquote
6
- from pathlib import Path
7
- from .swiftcli import CLI, option, argument, group
8
- from curl_cffi import requests
9
- import pyreqwest_impersonate as pri
10
- from .webscout_search import WEBS
11
- from .utils import json_dumps, json_loads
12
- from .version import __version__
13
- from .Litlogger import LitLogger, LogFormat, ColorScheme
14
- from rich.console import Console
15
- from rich.panel import Panel
16
- from rich.markdown import Markdown
17
- from rich.table import Table
18
- from rich.style import Style
19
- from rich.text import Text
20
- from rich.align import Align
21
- from rich.progress import track, Progress
22
- from rich.prompt import Prompt, Confirm
23
- from rich.columns import Columns
24
- from pyfiglet import figlet_format
25
-
26
- logger = LitLogger(
27
- name="webscout",
28
- format=LogFormat.MODERN_EMOJI,
29
- color_scheme=ColorScheme.CYBERPUNK,
30
- console_output=True
31
- )
32
-
33
- COLORS = {
34
- 0: "black",
35
- 1: "red",
36
- 2: "green",
37
- 3: "yellow",
38
- 4: "blue",
39
- 5: "magenta",
40
- 6: "cyan",
41
- 7: "bright_black",
42
- 8: "bright_red",
43
- 9: "bright_green",
44
- 10: "bright_yellow",
45
- 11: "bright_blue",
46
- 12: "bright_magenta",
47
- 13: "bright_cyan",
48
- 14: "white",
49
- 15: "bright_white",
50
- }
51
-
52
- def _print_data(data):
53
- """Prints data using rich panels and markdown."""
54
- console = Console()
55
- if data:
56
- for i, e in enumerate(data, start=1):
57
- table = Table(show_header=False, show_lines=True, expand=True, box=None)
58
- table.add_column("Key", style="cyan", no_wrap=True, width=15)
59
- table.add_column("Value", style="white")
60
-
61
- for j, (k, v) in enumerate(e.items(), start=1):
62
- if v:
63
- width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
64
- k = "language" if k == "detected_language" else k
65
- text = Text(str(v), style="white")
66
- text = text.wrap(width=width, console=console)
67
- else:
68
- text = Text(str(v), style="white")
69
- table.add_row(k, text)
70
-
71
- console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
72
- console.print("\n")
73
-
74
- # Initialize CLI app
75
- app = CLI(name="webscout", help="Search the web with a rich UI", version=__version__)
76
-
77
- @app.command()
78
- def version():
79
- """Show the version of webscout."""
80
- console = Console()
81
- console.print(f"[bold green]webscout[/bold green] version: {__version__}")
82
-
83
- @app.command()
84
- @option("--proxy", help="Proxy URL to use for requests")
85
- @option("--model", "-m", help="AI model to use", default="gpt-4o-mini", type=str)
86
- def chat(proxy: str = None, model: str = "gpt-4o-mini"):
87
- """Interactive AI chat using DuckDuckGo's AI."""
88
- webs = WEBS(proxy=proxy)
89
- console = Console()
90
-
91
- # Display header
92
- console.print(f"[bold blue]{figlet_format('Webscout Chat')}[/]\n", justify="center")
93
- console.print(f"[bold green]Using model:[/] {model}\n")
94
- console.print("[cyan]Type your message and press Enter. Press Ctrl+C or type 'exit' to quit.[/]\n")
95
-
96
- # Start chat loop
97
- try:
98
- while True:
99
- try:
100
- user_input = input("You: ").strip()
101
- if not user_input or user_input.lower() in ['exit', 'quit']:
102
- break
103
-
104
- logger.info(f"Sending message to {model}")
105
- response = webs.chat(keywords=user_input, model=model)
106
- console.print(f"\nAI: {response}\n")
107
- logger.success("Received response from AI")
108
-
109
- except Exception as e:
110
- logger.error(f"Error in chat: {str(e)}")
111
- console.print(f"[bold red]Error:[/] {str(e)}\n")
112
-
113
- except KeyboardInterrupt:
114
- logger.info("Chat session terminated by user")
115
-
116
- console.print("\n[cyan]Chat session ended. Goodbye![/]")
117
-
118
- @app.command()
119
- @option("--keywords", "-k", help="Search keywords", required=True)
120
- @option("--region", "-r", help="Region for search results", default="wt-wt")
121
- @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
122
- @option("--timelimit", "-t", help="Time limit for results", default=None)
123
- @option("--backend", "-b", help="Search backend to use", default="api")
124
- @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
125
- @option("--proxy", "-p", help="Proxy URL to use for requests")
126
- def text(keywords: str, region: str, safesearch: str, timelimit: str, backend: str, max_results: int, proxy: str = None):
127
- """Perform a text search using DuckDuckGo API."""
128
- webs = WEBS(proxy=proxy)
129
- try:
130
- results = webs.text(keywords, region, safesearch, timelimit, backend, max_results)
131
- _print_data(results)
132
- except Exception as e:
133
- logger.error(f"Error in text search: {e}")
134
- raise e
135
-
136
- @app.command()
137
- @option("--keywords", "-k", help="Search keywords", required=True)
138
- @option("--proxy", "-p", help="Proxy URL to use for requests")
139
- def answers(keywords: str, proxy: str = None):
140
- """Perform an answers search using DuckDuckGo API."""
141
- webs = WEBS(proxy=proxy)
142
- try:
143
- results = webs.answers(keywords)
144
- _print_data(results)
145
- except Exception as e:
146
- logger.error(f"Error in answers search: {e}")
147
- raise e
148
-
149
- @app.command()
150
- @option("--keywords", "-k", help="Search keywords", required=True)
151
- @option("--region", "-r", help="Region for search results", default="wt-wt")
152
- @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
153
- @option("--timelimit", "-t", help="Time limit for results", default=None)
154
- @option("--size", "-size", help="Image size", default=None)
155
- @option("--color", "-c", help="Image color", default=None)
156
- @option("--type", "-type", help="Image type", default=None)
157
- @option("--layout", "-l", help="Image layout", default=None)
158
- @option("--license", "-lic", help="Image license", default=None)
159
- @option("--max-results", "-m", help="Maximum number of results", type=int, default=90)
160
- @option("--proxy", "-p", help="Proxy URL to use for requests")
161
- def images(
162
- keywords: str,
163
- region: str,
164
- safesearch: str,
165
- timelimit: str,
166
- size: str,
167
- color: str,
168
- type: str,
169
- layout: str,
170
- license: str,
171
- max_results: int,
172
- proxy: str = None,
173
- ):
174
- """Perform an images search using DuckDuckGo API."""
175
- webs = WEBS(proxy=proxy)
176
- try:
177
- results = webs.images(keywords, region, safesearch, timelimit, size, color, type, layout, license, max_results)
178
- _print_data(results)
179
- except Exception as e:
180
- logger.error(f"Error in images search: {e}")
181
- raise e
182
-
183
- @app.command()
184
- @option("--keywords", "-k", help="Search keywords", required=True)
185
- @option("--region", "-r", help="Region for search results", default="wt-wt")
186
- @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
187
- @option("--timelimit", "-t", help="Time limit for results", default=None)
188
- @option("--resolution", "-res", help="Video resolution", default=None)
189
- @option("--duration", "-d", help="Video duration", default=None)
190
- @option("--license", "-lic", help="Video license", default=None)
191
- @option("--max-results", "-m", help="Maximum number of results", type=int, default=50)
192
- @option("--proxy", "-p", help="Proxy URL to use for requests")
193
- def videos(
194
- keywords: str,
195
- region: str,
196
- safesearch: str,
197
- timelimit: str,
198
- resolution: str,
199
- duration: str,
200
- license: str,
201
- max_results: int,
202
- proxy: str = None,
203
- ):
204
- """Perform a videos search using DuckDuckGo API."""
205
- webs = WEBS(proxy=proxy)
206
- try:
207
- results = webs.videos(keywords, region, safesearch, timelimit, resolution, duration, license, max_results)
208
- _print_data(results)
209
- except Exception as e:
210
- logger.error(f"Error in videos search: {e}")
211
- raise e
212
-
213
- @app.command()
214
- @option("--keywords", "-k", help="Search keywords", required=True)
215
- @option("--region", "-r", help="Region for search results", default="wt-wt")
216
- @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
217
- @option("--timelimit", "-t", help="Time limit for results", default=None)
218
- @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
219
- @option("--proxy", "-p", help="Proxy URL to use for requests")
220
- def news(keywords: str, region: str, safesearch: str, timelimit: str, max_results: int, proxy: str = None):
221
- """Perform a news search using DuckDuckGo API."""
222
- webs = WEBS(proxy=proxy)
223
- try:
224
- results = webs.news(keywords, region, safesearch, timelimit, max_results)
225
- _print_data(results)
226
- except Exception as e:
227
- logger.error(f"Error in news search: {e}")
228
- raise e
229
-
230
- @app.command()
231
- @option("--keywords", "-k", help="Search keywords", required=True)
232
- @option("--place", "-p", help="Simplified search - if set, the other parameters are not used")
233
- @option("--street", "-s", help="House number/street")
234
- @option("--city", "-c", help="City of search")
235
- @option("--county", "-county", help="County of search")
236
- @option("--state", "-state", help="State of search")
237
- @option("--country", "-country", help="Country of search")
238
- @option("--postalcode", "-post", help="Postal code of search")
239
- @option("--latitude", "-lat", help="Geographic coordinate (north-south position)")
240
- @option("--longitude", "-lon", help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used")
241
- @option("--radius", "-r", help="Expand the search square by the distance in kilometers", type=int, default=0)
242
- @option("--max-results", "-m", help="Number of results", type=int, default=50)
243
- @option("--proxy", "-p", help="Proxy URL to use for requests")
244
- def maps(
245
- keywords: str,
246
- place: str,
247
- street: str,
248
- city: str,
249
- county: str,
250
- state: str,
251
- country: str,
252
- postalcode: str,
253
- latitude: str,
254
- longitude: str,
255
- radius: int,
256
- max_results: int,
257
- proxy: str = None,
258
- ):
259
- """Perform a maps search using DuckDuckGo API."""
260
- webs = WEBS(proxy=proxy)
261
- try:
262
- results = webs.maps(
263
- keywords,
264
- place,
265
- street,
266
- city,
267
- county,
268
- state,
269
- country,
270
- postalcode,
271
- latitude,
272
- longitude,
273
- radius,
274
- max_results,
275
- )
276
- _print_data(results)
277
- except Exception as e:
278
- logger.error(f"Error in maps search: {e}")
279
- raise e
280
-
281
- @app.command()
282
- @option("--keywords", "-k", help="Text for translation", required=True)
283
- @option("--from", "-f", help="Language to translate from (defaults automatically)")
284
- @option("--to", "-t", help="Language to translate to (default: 'en')", default="en")
285
- @option("--proxy", "-p", help="Proxy URL to use for requests")
286
- def translate(keywords: str, from_: str, to: str, proxy: str = None):
287
- """Perform translation using DuckDuckGo API."""
288
- webs = WEBS(proxy=proxy)
289
- try:
290
- results = webs.translate(keywords, from_, to)
291
- _print_data(results)
292
- except Exception as e:
293
- logger.error(f"Error in translation: {e}")
294
- raise e
295
-
296
- @app.command()
297
- @option("--keywords", "-k", help="Search keywords", required=True)
298
- @option("--region", "-r", help="Region for search results", default="wt-wt")
299
- @option("--proxy", "-p", help="Proxy URL to use for requests")
300
- def suggestions(keywords: str, region: str, proxy: str = None):
301
- """Perform a suggestions search using DuckDuckGo API."""
302
- webs = WEBS(proxy=proxy)
303
- try:
304
- results = webs.suggestions(keywords, region)
305
- _print_data(results)
306
- except Exception as e:
307
- logger.error(f"Error in suggestions search: {e}")
308
- raise e
309
-
310
- def main():
311
- """Main entry point for the CLI."""
312
- try:
313
- app.run()
314
- except Exception as e:
315
- logger.error(f"Error: {e}")
316
- sys.exit(1)
317
-
318
- if __name__ == "__main__":
319
- main()
1
+ import os
2
+ import sys
3
+ from concurrent.futures import ThreadPoolExecutor, as_completed
4
+ from datetime import datetime
5
+ from urllib.parse import unquote
6
+ from pathlib import Path
7
+ from .swiftcli import CLI, option, argument, group
8
+ from curl_cffi import requests
9
+ import pyreqwest_impersonate as pri
10
+ from .webscout_search import WEBS
11
+ from .utils import json_dumps, json_loads
12
+ from .version import __version__
13
+ from .Litlogger import LitLogger, LogFormat, ColorScheme
14
+ from rich.console import Console
15
+ from rich.panel import Panel
16
+ from rich.markdown import Markdown
17
+ from rich.table import Table
18
+ from rich.style import Style
19
+ from rich.text import Text
20
+ from rich.align import Align
21
+ from rich.progress import track, Progress
22
+ from rich.prompt import Prompt, Confirm
23
+ from rich.columns import Columns
24
+ from pyfiglet import figlet_format
25
+
26
+ logger = LitLogger(
27
+ name="webscout",
28
+ format=LogFormat.MODERN_EMOJI,
29
+ color_scheme=ColorScheme.CYBERPUNK,
30
+ console_output=True
31
+ )
32
+
33
+ COLORS = {
34
+ 0: "black",
35
+ 1: "red",
36
+ 2: "green",
37
+ 3: "yellow",
38
+ 4: "blue",
39
+ 5: "magenta",
40
+ 6: "cyan",
41
+ 7: "bright_black",
42
+ 8: "bright_red",
43
+ 9: "bright_green",
44
+ 10: "bright_yellow",
45
+ 11: "bright_blue",
46
+ 12: "bright_magenta",
47
+ 13: "bright_cyan",
48
+ 14: "white",
49
+ 15: "bright_white",
50
+ }
51
+
52
+ def _print_data(data):
53
+ """Prints data using rich panels and markdown."""
54
+ console = Console()
55
+ if data:
56
+ for i, e in enumerate(data, start=1):
57
+ table = Table(show_header=False, show_lines=True, expand=True, box=None)
58
+ table.add_column("Key", style="cyan", no_wrap=True, width=15)
59
+ table.add_column("Value", style="white")
60
+
61
+ for j, (k, v) in enumerate(e.items(), start=1):
62
+ if v:
63
+ width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
64
+ k = "language" if k == "detected_language" else k
65
+ text = Text(str(v), style="white")
66
+ text = text.wrap(width=width, console=console)
67
+ else:
68
+ text = Text(str(v), style="white")
69
+ table.add_row(k, text)
70
+
71
+ console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
72
+ console.print("\n")
73
+
74
+ # Initialize CLI app
75
+ app = CLI(name="webscout", help="Search the web with a rich UI", version=__version__)
76
+
77
+ @app.command()
78
+ def version():
79
+ """Show the version of webscout."""
80
+ console = Console()
81
+ console.print(f"[bold green]webscout[/bold green] version: {__version__}")
82
+
83
+ @app.command()
84
+ @option("--proxy", help="Proxy URL to use for requests")
85
+ @option("--model", "-m", help="AI model to use", default="gpt-4o-mini", type=str)
86
+ def chat(proxy: str = None, model: str = "gpt-4o-mini"):
87
+ """Interactive AI chat using DuckDuckGo's AI."""
88
+ webs = WEBS(proxy=proxy)
89
+ console = Console()
90
+
91
+ # Display header
92
+ console.print(f"[bold blue]{figlet_format('Webscout Chat')}[/]\n", justify="center")
93
+ console.print(f"[bold green]Using model:[/] {model}\n")
94
+ console.print("[cyan]Type your message and press Enter. Press Ctrl+C or type 'exit' to quit.[/]\n")
95
+
96
+ # Start chat loop
97
+ try:
98
+ while True:
99
+ try:
100
+ user_input = input("You: ").strip()
101
+ if not user_input or user_input.lower() in ['exit', 'quit']:
102
+ break
103
+
104
+ logger.info(f"Sending message to {model}")
105
+ response = webs.chat(keywords=user_input, model=model)
106
+ console.print(f"\nAI: {response}\n")
107
+ logger.success("Received response from AI")
108
+
109
+ except Exception as e:
110
+ logger.error(f"Error in chat: {str(e)}")
111
+ console.print(f"[bold red]Error:[/] {str(e)}\n")
112
+
113
+ except KeyboardInterrupt:
114
+ logger.info("Chat session terminated by user")
115
+
116
+ console.print("\n[cyan]Chat session ended. Goodbye![/]")
117
+
118
+ @app.command()
119
+ @option("--keywords", "-k", help="Search keywords", required=True)
120
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
121
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
122
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
123
+ @option("--backend", "-b", help="Search backend to use", default="api")
124
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
125
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
126
+ def text(keywords: str, region: str, safesearch: str, timelimit: str, backend: str, max_results: int, proxy: str = None):
127
+ """Perform a text search using DuckDuckGo API."""
128
+ webs = WEBS(proxy=proxy)
129
+ try:
130
+ results = webs.text(keywords, region, safesearch, timelimit, backend, max_results)
131
+ _print_data(results)
132
+ except Exception as e:
133
+ logger.error(f"Error in text search: {e}")
134
+ raise e
135
+
136
+ @app.command()
137
+ @option("--keywords", "-k", help="Search keywords", required=True)
138
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
139
+ def answers(keywords: str, proxy: str = None):
140
+ """Perform an answers search using DuckDuckGo API."""
141
+ webs = WEBS(proxy=proxy)
142
+ try:
143
+ results = webs.answers(keywords)
144
+ _print_data(results)
145
+ except Exception as e:
146
+ logger.error(f"Error in answers search: {e}")
147
+ raise e
148
+
149
+ @app.command()
150
+ @option("--keywords", "-k", help="Search keywords", required=True)
151
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
152
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
153
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
154
+ @option("--size", "-size", help="Image size", default=None)
155
+ @option("--color", "-c", help="Image color", default=None)
156
+ @option("--type", "-type", help="Image type", default=None)
157
+ @option("--layout", "-l", help="Image layout", default=None)
158
+ @option("--license", "-lic", help="Image license", default=None)
159
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=90)
160
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
161
+ def images(
162
+ keywords: str,
163
+ region: str,
164
+ safesearch: str,
165
+ timelimit: str,
166
+ size: str,
167
+ color: str,
168
+ type: str,
169
+ layout: str,
170
+ license: str,
171
+ max_results: int,
172
+ proxy: str = None,
173
+ ):
174
+ """Perform an images search using DuckDuckGo API."""
175
+ webs = WEBS(proxy=proxy)
176
+ try:
177
+ results = webs.images(keywords, region, safesearch, timelimit, size, color, type, layout, license, max_results)
178
+ _print_data(results)
179
+ except Exception as e:
180
+ logger.error(f"Error in images search: {e}")
181
+ raise e
182
+
183
+ @app.command()
184
+ @option("--keywords", "-k", help="Search keywords", required=True)
185
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
186
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
187
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
188
+ @option("--resolution", "-res", help="Video resolution", default=None)
189
+ @option("--duration", "-d", help="Video duration", default=None)
190
+ @option("--license", "-lic", help="Video license", default=None)
191
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=50)
192
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
193
+ def videos(
194
+ keywords: str,
195
+ region: str,
196
+ safesearch: str,
197
+ timelimit: str,
198
+ resolution: str,
199
+ duration: str,
200
+ license: str,
201
+ max_results: int,
202
+ proxy: str = None,
203
+ ):
204
+ """Perform a videos search using DuckDuckGo API."""
205
+ webs = WEBS(proxy=proxy)
206
+ try:
207
+ results = webs.videos(keywords, region, safesearch, timelimit, resolution, duration, license, max_results)
208
+ _print_data(results)
209
+ except Exception as e:
210
+ logger.error(f"Error in videos search: {e}")
211
+ raise e
212
+
213
+ @app.command()
214
+ @option("--keywords", "-k", help="Search keywords", required=True)
215
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
216
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
217
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
218
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
219
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
220
+ def news(keywords: str, region: str, safesearch: str, timelimit: str, max_results: int, proxy: str = None):
221
+ """Perform a news search using DuckDuckGo API."""
222
+ webs = WEBS(proxy=proxy)
223
+ try:
224
+ results = webs.news(keywords, region, safesearch, timelimit, max_results)
225
+ _print_data(results)
226
+ except Exception as e:
227
+ logger.error(f"Error in news search: {e}")
228
+ raise e
229
+
230
+ @app.command()
231
+ @option("--keywords", "-k", help="Search keywords", required=True)
232
+ @option("--place", "-p", help="Simplified search - if set, the other parameters are not used")
233
+ @option("--street", "-s", help="House number/street")
234
+ @option("--city", "-c", help="City of search")
235
+ @option("--county", "-county", help="County of search")
236
+ @option("--state", "-state", help="State of search")
237
+ @option("--country", "-country", help="Country of search")
238
+ @option("--postalcode", "-post", help="Postal code of search")
239
+ @option("--latitude", "-lat", help="Geographic coordinate (north-south position)")
240
+ @option("--longitude", "-lon", help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used")
241
+ @option("--radius", "-r", help="Expand the search square by the distance in kilometers", type=int, default=0)
242
+ @option("--max-results", "-m", help="Number of results", type=int, default=50)
243
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
244
+ def maps(
245
+ keywords: str,
246
+ place: str,
247
+ street: str,
248
+ city: str,
249
+ county: str,
250
+ state: str,
251
+ country: str,
252
+ postalcode: str,
253
+ latitude: str,
254
+ longitude: str,
255
+ radius: int,
256
+ max_results: int,
257
+ proxy: str = None,
258
+ ):
259
+ """Perform a maps search using DuckDuckGo API."""
260
+ webs = WEBS(proxy=proxy)
261
+ try:
262
+ results = webs.maps(
263
+ keywords,
264
+ place,
265
+ street,
266
+ city,
267
+ county,
268
+ state,
269
+ country,
270
+ postalcode,
271
+ latitude,
272
+ longitude,
273
+ radius,
274
+ max_results,
275
+ )
276
+ _print_data(results)
277
+ except Exception as e:
278
+ logger.error(f"Error in maps search: {e}")
279
+ raise e
280
+
281
+ @app.command()
282
+ @option("--keywords", "-k", help="Text for translation", required=True)
283
+ @option("--from", "-f", help="Language to translate from (defaults automatically)")
284
+ @option("--to", "-t", help="Language to translate to (default: 'en')", default="en")
285
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
286
+ def translate(keywords: str, from_: str, to: str, proxy: str = None):
287
+ """Perform translation using DuckDuckGo API."""
288
+ webs = WEBS(proxy=proxy)
289
+ try:
290
+ results = webs.translate(keywords, from_, to)
291
+ _print_data(results)
292
+ except Exception as e:
293
+ logger.error(f"Error in translation: {e}")
294
+ raise e
295
+
296
+ @app.command()
297
+ @option("--keywords", "-k", help="Search keywords", required=True)
298
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
299
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
300
+ def suggestions(keywords: str, region: str, proxy: str = None):
301
+ """Perform a suggestions search using DuckDuckGo API."""
302
+ webs = WEBS(proxy=proxy)
303
+ try:
304
+ results = webs.suggestions(keywords, region)
305
+ _print_data(results)
306
+ except Exception as e:
307
+ logger.error(f"Error in suggestions search: {e}")
308
+ raise e
309
+
310
+ def main():
311
+ """Main entry point for the CLI."""
312
+ try:
313
+ app.run()
314
+ except Exception as e:
315
+ logger.error(f"Error: {e}")
316
+ sys.exit(1)
317
+
318
+ if __name__ == "__main__":
319
+ main()