webscout 8.3.7__py3-none-any.whl → 2025.10.13__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 (306) hide show
  1. webscout/AIauto.py +250 -250
  2. webscout/AIbase.py +379 -379
  3. webscout/AIutel.py +60 -60
  4. webscout/Bard.py +1012 -1012
  5. webscout/Bing_search.py +417 -417
  6. webscout/DWEBS.py +529 -529
  7. webscout/Extra/Act.md +309 -309
  8. webscout/Extra/GitToolkit/__init__.py +10 -10
  9. webscout/Extra/GitToolkit/gitapi/README.md +110 -110
  10. webscout/Extra/GitToolkit/gitapi/__init__.py +11 -11
  11. webscout/Extra/GitToolkit/gitapi/repository.py +195 -195
  12. webscout/Extra/GitToolkit/gitapi/user.py +96 -96
  13. webscout/Extra/GitToolkit/gitapi/utils.py +61 -61
  14. webscout/Extra/YTToolkit/README.md +375 -375
  15. webscout/Extra/YTToolkit/YTdownloader.py +956 -956
  16. webscout/Extra/YTToolkit/__init__.py +2 -2
  17. webscout/Extra/YTToolkit/transcriber.py +475 -475
  18. webscout/Extra/YTToolkit/ytapi/README.md +44 -44
  19. webscout/Extra/YTToolkit/ytapi/__init__.py +6 -6
  20. webscout/Extra/YTToolkit/ytapi/channel.py +307 -307
  21. webscout/Extra/YTToolkit/ytapi/errors.py +13 -13
  22. webscout/Extra/YTToolkit/ytapi/extras.py +118 -118
  23. webscout/Extra/YTToolkit/ytapi/https.py +88 -88
  24. webscout/Extra/YTToolkit/ytapi/patterns.py +61 -61
  25. webscout/Extra/YTToolkit/ytapi/playlist.py +58 -58
  26. webscout/Extra/YTToolkit/ytapi/pool.py +7 -7
  27. webscout/Extra/YTToolkit/ytapi/query.py +39 -39
  28. webscout/Extra/YTToolkit/ytapi/stream.py +62 -62
  29. webscout/Extra/YTToolkit/ytapi/utils.py +62 -62
  30. webscout/Extra/YTToolkit/ytapi/video.py +232 -232
  31. webscout/Extra/autocoder/__init__.py +9 -9
  32. webscout/Extra/autocoder/autocoder.py +1105 -1105
  33. webscout/Extra/autocoder/autocoder_utiles.py +332 -332
  34. webscout/Extra/gguf.md +429 -429
  35. webscout/Extra/gguf.py +1213 -1213
  36. webscout/Extra/tempmail/README.md +487 -487
  37. webscout/Extra/tempmail/__init__.py +27 -27
  38. webscout/Extra/tempmail/async_utils.py +140 -140
  39. webscout/Extra/tempmail/base.py +160 -160
  40. webscout/Extra/tempmail/cli.py +186 -186
  41. webscout/Extra/tempmail/emailnator.py +84 -84
  42. webscout/Extra/tempmail/mail_tm.py +360 -360
  43. webscout/Extra/tempmail/temp_mail_io.py +291 -291
  44. webscout/Extra/weather.md +281 -281
  45. webscout/Extra/weather.py +193 -193
  46. webscout/Litlogger/README.md +10 -10
  47. webscout/Litlogger/__init__.py +15 -15
  48. webscout/Litlogger/formats.py +13 -13
  49. webscout/Litlogger/handlers.py +121 -121
  50. webscout/Litlogger/levels.py +13 -13
  51. webscout/Litlogger/logger.py +134 -134
  52. webscout/Provider/AISEARCH/Perplexity.py +332 -332
  53. webscout/Provider/AISEARCH/README.md +279 -279
  54. webscout/Provider/AISEARCH/__init__.py +16 -1
  55. webscout/Provider/AISEARCH/felo_search.py +206 -206
  56. webscout/Provider/AISEARCH/genspark_search.py +323 -323
  57. webscout/Provider/AISEARCH/hika_search.py +185 -185
  58. webscout/Provider/AISEARCH/iask_search.py +410 -410
  59. webscout/Provider/AISEARCH/monica_search.py +219 -219
  60. webscout/Provider/AISEARCH/scira_search.py +316 -316
  61. webscout/Provider/AISEARCH/stellar_search.py +177 -177
  62. webscout/Provider/AISEARCH/webpilotai_search.py +255 -255
  63. webscout/Provider/Aitopia.py +314 -314
  64. webscout/Provider/Andi.py +1 -1
  65. webscout/Provider/Apriel.py +306 -0
  66. webscout/Provider/ChatGPTClone.py +237 -236
  67. webscout/Provider/ChatSandbox.py +343 -343
  68. webscout/Provider/Cloudflare.py +324 -324
  69. webscout/Provider/Cohere.py +208 -208
  70. webscout/Provider/Deepinfra.py +370 -366
  71. webscout/Provider/ExaAI.py +260 -260
  72. webscout/Provider/ExaChat.py +308 -308
  73. webscout/Provider/Flowith.py +221 -221
  74. webscout/Provider/GMI.py +293 -0
  75. webscout/Provider/Gemini.py +164 -164
  76. webscout/Provider/GeminiProxy.py +167 -167
  77. webscout/Provider/GithubChat.py +371 -372
  78. webscout/Provider/Groq.py +800 -800
  79. webscout/Provider/HeckAI.py +383 -383
  80. webscout/Provider/Jadve.py +282 -282
  81. webscout/Provider/K2Think.py +307 -307
  82. webscout/Provider/Koboldai.py +205 -205
  83. webscout/Provider/LambdaChat.py +423 -423
  84. webscout/Provider/Nemotron.py +244 -244
  85. webscout/Provider/Netwrck.py +248 -248
  86. webscout/Provider/OLLAMA.py +395 -395
  87. webscout/Provider/OPENAI/Cloudflare.py +393 -393
  88. webscout/Provider/OPENAI/FalconH1.py +451 -451
  89. webscout/Provider/OPENAI/FreeGemini.py +296 -296
  90. webscout/Provider/OPENAI/K2Think.py +431 -431
  91. webscout/Provider/OPENAI/NEMOTRON.py +240 -240
  92. webscout/Provider/OPENAI/PI.py +427 -427
  93. webscout/Provider/OPENAI/README.md +959 -959
  94. webscout/Provider/OPENAI/TogetherAI.py +345 -345
  95. webscout/Provider/OPENAI/TwoAI.py +465 -465
  96. webscout/Provider/OPENAI/__init__.py +33 -18
  97. webscout/Provider/OPENAI/base.py +248 -248
  98. webscout/Provider/OPENAI/chatglm.py +528 -0
  99. webscout/Provider/OPENAI/chatgpt.py +592 -592
  100. webscout/Provider/OPENAI/chatgptclone.py +521 -521
  101. webscout/Provider/OPENAI/chatsandbox.py +202 -202
  102. webscout/Provider/OPENAI/deepinfra.py +318 -314
  103. webscout/Provider/OPENAI/e2b.py +1665 -1665
  104. webscout/Provider/OPENAI/exaai.py +420 -420
  105. webscout/Provider/OPENAI/exachat.py +452 -452
  106. webscout/Provider/OPENAI/friendli.py +232 -232
  107. webscout/Provider/OPENAI/{refact.py → gmi.py} +324 -274
  108. webscout/Provider/OPENAI/groq.py +364 -364
  109. webscout/Provider/OPENAI/heckai.py +314 -314
  110. webscout/Provider/OPENAI/llmchatco.py +337 -337
  111. webscout/Provider/OPENAI/netwrck.py +355 -355
  112. webscout/Provider/OPENAI/oivscode.py +290 -290
  113. webscout/Provider/OPENAI/opkfc.py +518 -518
  114. webscout/Provider/OPENAI/pydantic_imports.py +1 -1
  115. webscout/Provider/OPENAI/scirachat.py +535 -535
  116. webscout/Provider/OPENAI/sonus.py +308 -308
  117. webscout/Provider/OPENAI/standardinput.py +442 -442
  118. webscout/Provider/OPENAI/textpollinations.py +340 -340
  119. webscout/Provider/OPENAI/toolbaz.py +419 -416
  120. webscout/Provider/OPENAI/typefully.py +362 -362
  121. webscout/Provider/OPENAI/utils.py +295 -295
  122. webscout/Provider/OPENAI/venice.py +436 -436
  123. webscout/Provider/OPENAI/wisecat.py +387 -387
  124. webscout/Provider/OPENAI/writecream.py +166 -166
  125. webscout/Provider/OPENAI/x0gpt.py +378 -378
  126. webscout/Provider/OPENAI/yep.py +389 -389
  127. webscout/Provider/OpenGPT.py +230 -230
  128. webscout/Provider/Openai.py +243 -243
  129. webscout/Provider/PI.py +405 -405
  130. webscout/Provider/Perplexitylabs.py +430 -430
  131. webscout/Provider/QwenLM.py +272 -272
  132. webscout/Provider/STT/__init__.py +16 -1
  133. webscout/Provider/Sambanova.py +257 -257
  134. webscout/Provider/StandardInput.py +309 -309
  135. webscout/Provider/TTI/README.md +82 -82
  136. webscout/Provider/TTI/__init__.py +33 -18
  137. webscout/Provider/TTI/aiarta.py +413 -413
  138. webscout/Provider/TTI/base.py +136 -136
  139. webscout/Provider/TTI/bing.py +243 -243
  140. webscout/Provider/TTI/gpt1image.py +149 -149
  141. webscout/Provider/TTI/imagen.py +196 -196
  142. webscout/Provider/TTI/infip.py +211 -211
  143. webscout/Provider/TTI/magicstudio.py +232 -232
  144. webscout/Provider/TTI/monochat.py +219 -219
  145. webscout/Provider/TTI/piclumen.py +214 -214
  146. webscout/Provider/TTI/pixelmuse.py +232 -232
  147. webscout/Provider/TTI/pollinations.py +232 -232
  148. webscout/Provider/TTI/together.py +288 -288
  149. webscout/Provider/TTI/utils.py +12 -12
  150. webscout/Provider/TTI/venice.py +367 -367
  151. webscout/Provider/TTS/README.md +192 -192
  152. webscout/Provider/TTS/__init__.py +33 -18
  153. webscout/Provider/TTS/parler.py +110 -110
  154. webscout/Provider/TTS/streamElements.py +333 -333
  155. webscout/Provider/TTS/utils.py +280 -280
  156. webscout/Provider/TeachAnything.py +237 -237
  157. webscout/Provider/TextPollinationsAI.py +310 -310
  158. webscout/Provider/TogetherAI.py +356 -356
  159. webscout/Provider/TwoAI.py +312 -312
  160. webscout/Provider/TypliAI.py +311 -311
  161. webscout/Provider/UNFINISHED/ChatHub.py +208 -208
  162. webscout/Provider/UNFINISHED/ChutesAI.py +313 -313
  163. webscout/Provider/UNFINISHED/GizAI.py +294 -294
  164. webscout/Provider/UNFINISHED/Marcus.py +198 -198
  165. webscout/Provider/UNFINISHED/Qodo.py +477 -477
  166. webscout/Provider/UNFINISHED/VercelAIGateway.py +338 -338
  167. webscout/Provider/UNFINISHED/XenAI.py +324 -324
  168. webscout/Provider/UNFINISHED/Youchat.py +330 -330
  169. webscout/Provider/UNFINISHED/liner.py +334 -0
  170. webscout/Provider/UNFINISHED/liner_api_request.py +262 -262
  171. webscout/Provider/UNFINISHED/puterjs.py +634 -634
  172. webscout/Provider/UNFINISHED/samurai.py +223 -223
  173. webscout/Provider/UNFINISHED/test_lmarena.py +119 -119
  174. webscout/Provider/Venice.py +250 -250
  175. webscout/Provider/VercelAI.py +256 -256
  176. webscout/Provider/WiseCat.py +231 -231
  177. webscout/Provider/WrDoChat.py +366 -366
  178. webscout/Provider/__init__.py +33 -18
  179. webscout/Provider/ai4chat.py +174 -174
  180. webscout/Provider/akashgpt.py +331 -331
  181. webscout/Provider/cerebras.py +446 -446
  182. webscout/Provider/chatglm.py +394 -301
  183. webscout/Provider/cleeai.py +211 -211
  184. webscout/Provider/elmo.py +282 -282
  185. webscout/Provider/geminiapi.py +208 -208
  186. webscout/Provider/granite.py +261 -261
  187. webscout/Provider/hermes.py +263 -263
  188. webscout/Provider/julius.py +223 -223
  189. webscout/Provider/learnfastai.py +309 -309
  190. webscout/Provider/llama3mitril.py +214 -214
  191. webscout/Provider/llmchat.py +243 -243
  192. webscout/Provider/llmchatco.py +290 -290
  193. webscout/Provider/meta.py +801 -801
  194. webscout/Provider/oivscode.py +309 -309
  195. webscout/Provider/scira_chat.py +383 -383
  196. webscout/Provider/searchchat.py +292 -292
  197. webscout/Provider/sonus.py +258 -258
  198. webscout/Provider/toolbaz.py +370 -367
  199. webscout/Provider/turboseek.py +273 -273
  200. webscout/Provider/typefully.py +207 -207
  201. webscout/Provider/yep.py +372 -372
  202. webscout/__init__.py +27 -31
  203. webscout/__main__.py +5 -5
  204. webscout/auth/api_key_manager.py +189 -189
  205. webscout/auth/config.py +175 -175
  206. webscout/auth/models.py +185 -185
  207. webscout/auth/routes.py +663 -664
  208. webscout/auth/simple_logger.py +236 -236
  209. webscout/cli.py +523 -523
  210. webscout/conversation.py +438 -438
  211. webscout/exceptions.py +361 -361
  212. webscout/litagent/Readme.md +298 -298
  213. webscout/litagent/__init__.py +28 -28
  214. webscout/litagent/agent.py +581 -581
  215. webscout/litagent/constants.py +59 -59
  216. webscout/litprinter/__init__.py +58 -58
  217. webscout/models.py +181 -181
  218. webscout/optimizers.py +419 -419
  219. webscout/prompt_manager.py +288 -288
  220. webscout/sanitize.py +1078 -1078
  221. webscout/scout/README.md +401 -401
  222. webscout/scout/__init__.py +8 -8
  223. webscout/scout/core/__init__.py +6 -6
  224. webscout/scout/core/crawler.py +297 -297
  225. webscout/scout/core/scout.py +706 -706
  226. webscout/scout/core/search_result.py +95 -95
  227. webscout/scout/core/text_analyzer.py +62 -62
  228. webscout/scout/core/text_utils.py +277 -277
  229. webscout/scout/core/web_analyzer.py +51 -51
  230. webscout/scout/element.py +599 -599
  231. webscout/scout/parsers/__init__.py +69 -69
  232. webscout/scout/parsers/html5lib_parser.py +172 -172
  233. webscout/scout/parsers/html_parser.py +236 -236
  234. webscout/scout/parsers/lxml_parser.py +178 -178
  235. webscout/scout/utils.py +37 -37
  236. webscout/search/__init__.py +51 -0
  237. webscout/search/base.py +195 -0
  238. webscout/search/duckduckgo_main.py +54 -0
  239. webscout/search/engines/__init__.py +48 -0
  240. webscout/search/engines/bing.py +84 -0
  241. webscout/search/engines/bing_news.py +52 -0
  242. webscout/search/engines/brave.py +43 -0
  243. webscout/search/engines/duckduckgo/__init__.py +25 -0
  244. webscout/search/engines/duckduckgo/answers.py +78 -0
  245. webscout/search/engines/duckduckgo/base.py +187 -0
  246. webscout/search/engines/duckduckgo/images.py +97 -0
  247. webscout/search/engines/duckduckgo/maps.py +168 -0
  248. webscout/search/engines/duckduckgo/news.py +68 -0
  249. webscout/search/engines/duckduckgo/suggestions.py +21 -0
  250. webscout/search/engines/duckduckgo/text.py +211 -0
  251. webscout/search/engines/duckduckgo/translate.py +47 -0
  252. webscout/search/engines/duckduckgo/videos.py +63 -0
  253. webscout/search/engines/duckduckgo/weather.py +74 -0
  254. webscout/search/engines/mojeek.py +37 -0
  255. webscout/search/engines/wikipedia.py +56 -0
  256. webscout/search/engines/yahoo.py +65 -0
  257. webscout/search/engines/yahoo_news.py +64 -0
  258. webscout/search/engines/yandex.py +43 -0
  259. webscout/search/engines/yep/__init__.py +13 -0
  260. webscout/search/engines/yep/base.py +32 -0
  261. webscout/search/engines/yep/images.py +99 -0
  262. webscout/search/engines/yep/suggestions.py +35 -0
  263. webscout/search/engines/yep/text.py +114 -0
  264. webscout/search/http_client.py +156 -0
  265. webscout/search/results.py +137 -0
  266. webscout/search/yep_main.py +44 -0
  267. webscout/swiftcli/Readme.md +323 -323
  268. webscout/swiftcli/__init__.py +95 -95
  269. webscout/swiftcli/core/__init__.py +7 -7
  270. webscout/swiftcli/core/cli.py +308 -308
  271. webscout/swiftcli/core/context.py +104 -104
  272. webscout/swiftcli/core/group.py +241 -241
  273. webscout/swiftcli/decorators/__init__.py +28 -28
  274. webscout/swiftcli/decorators/command.py +221 -221
  275. webscout/swiftcli/decorators/options.py +220 -220
  276. webscout/swiftcli/decorators/output.py +302 -302
  277. webscout/swiftcli/exceptions.py +21 -21
  278. webscout/swiftcli/plugins/__init__.py +9 -9
  279. webscout/swiftcli/plugins/base.py +135 -135
  280. webscout/swiftcli/plugins/manager.py +269 -269
  281. webscout/swiftcli/utils/__init__.py +59 -59
  282. webscout/swiftcli/utils/formatting.py +252 -252
  283. webscout/swiftcli/utils/parsing.py +267 -267
  284. webscout/update_checker.py +117 -117
  285. webscout/version.py +1 -1
  286. webscout/version.py.bak +2 -0
  287. webscout/zeroart/README.md +89 -89
  288. webscout/zeroart/__init__.py +134 -134
  289. webscout/zeroart/base.py +66 -66
  290. webscout/zeroart/effects.py +100 -100
  291. webscout/zeroart/fonts.py +1238 -1238
  292. {webscout-8.3.7.dist-info → webscout-2025.10.13.dist-info}/METADATA +936 -937
  293. webscout-2025.10.13.dist-info/RECORD +329 -0
  294. webscout/Provider/AISEARCH/DeepFind.py +0 -254
  295. webscout/Provider/OPENAI/Qwen3.py +0 -303
  296. webscout/Provider/OPENAI/qodo.py +0 -630
  297. webscout/Provider/OPENAI/xenai.py +0 -514
  298. webscout/tempid.py +0 -134
  299. webscout/webscout_search.py +0 -1183
  300. webscout/webscout_search_async.py +0 -649
  301. webscout/yep_search.py +0 -346
  302. webscout-8.3.7.dist-info/RECORD +0 -301
  303. {webscout-8.3.7.dist-info → webscout-2025.10.13.dist-info}/WHEEL +0 -0
  304. {webscout-8.3.7.dist-info → webscout-2025.10.13.dist-info}/entry_points.txt +0 -0
  305. {webscout-8.3.7.dist-info → webscout-2025.10.13.dist-info}/licenses/LICENSE.md +0 -0
  306. {webscout-8.3.7.dist-info → webscout-2025.10.13.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,54 @@
1
+ """DuckDuckGo unified search interface."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Dict, List, Optional
5
+ from .base import BaseSearch
6
+ from .engines.duckduckgo.text import DuckDuckGoTextSearch
7
+ from .engines.duckduckgo.images import DuckDuckGoImages
8
+ from .engines.duckduckgo.videos import DuckDuckGoVideos
9
+ from .engines.duckduckgo.news import DuckDuckGoNews
10
+ from .engines.duckduckgo.answers import DuckDuckGoAnswers
11
+ from .engines.duckduckgo.suggestions import DuckDuckGoSuggestions
12
+ from .engines.duckduckgo.maps import DuckDuckGoMaps
13
+ from .engines.duckduckgo.translate import DuckDuckGoTranslate
14
+ from .engines.duckduckgo.weather import DuckDuckGoWeather
15
+
16
+
17
+ class DuckDuckGoSearch(BaseSearch):
18
+ """Unified DuckDuckGo search interface."""
19
+
20
+ def text(self, keywords: str, region: str = "wt-wt", safesearch: str = "moderate", timelimit: Optional[str] = None, backend: str = "api", max_results: Optional[int] = None) -> List[Dict[str, str]]:
21
+ search = DuckDuckGoTextSearch()
22
+ return search.run(keywords, region, safesearch, timelimit, backend, max_results)
23
+
24
+ def images(self, keywords: str, region: str = "wt-wt", safesearch: str = "moderate", timelimit: Optional[str] = None, size: Optional[str] = None, color: Optional[str] = None, type_image: Optional[str] = None, layout: Optional[str] = None, license_image: Optional[str] = None, max_results: Optional[int] = None) -> List[Dict[str, str]]:
25
+ search = DuckDuckGoImages()
26
+ return search.run(keywords, region, safesearch, timelimit, size, color, type_image, layout, license_image, max_results)
27
+
28
+ def videos(self, keywords: str, region: str = "wt-wt", safesearch: str = "moderate", timelimit: Optional[str] = None, resolution: Optional[str] = None, duration: Optional[str] = None, license_videos: Optional[str] = None, max_results: Optional[int] = None) -> List[Dict[str, str]]:
29
+ search = DuckDuckGoVideos()
30
+ return search.run(keywords, region, safesearch, timelimit, resolution, duration, license_videos, max_results)
31
+
32
+ def news(self, keywords: str, region: str = "wt-wt", safesearch: str = "moderate", timelimit: Optional[str] = None, max_results: Optional[int] = None) -> List[Dict[str, str]]:
33
+ search = DuckDuckGoNews()
34
+ return search.run(keywords, region, safesearch, timelimit, max_results)
35
+
36
+ def answers(self, keywords: str) -> List[Dict[str, str]]:
37
+ search = DuckDuckGoAnswers()
38
+ return search.run(keywords)
39
+
40
+ def suggestions(self, keywords: str, region: str = "wt-wt") -> List[str]:
41
+ search = DuckDuckGoSuggestions()
42
+ return search.run(keywords, region)
43
+
44
+ def maps(self, keywords: str, place: Optional[str] = None, street: Optional[str] = None, city: Optional[str] = None, county: Optional[str] = None, state: Optional[str] = None, country: Optional[str] = None, postalcode: Optional[str] = None, latitude: Optional[str] = None, longitude: Optional[str] = None, radius: int = 0, max_results: Optional[int] = None) -> List[Dict[str, str]]:
45
+ search = DuckDuckGoMaps()
46
+ return search.run(keywords, place, street, city, county, state, country, postalcode, latitude, longitude, radius, max_results)
47
+
48
+ def translate(self, keywords: str, from_lang: Optional[str] = None, to_lang: str = "en") -> List[Dict[str, str]]:
49
+ search = DuckDuckGoTranslate()
50
+ return search.run(keywords, from_lang, to_lang)
51
+
52
+ def weather(self, keywords: str) -> List[Dict[str, str]]:
53
+ search = DuckDuckGoWeather()
54
+ return search.run(keywords)
@@ -0,0 +1,48 @@
1
+ """__init__.py for engines package - auto-discovers and registers search engines."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import inspect
7
+ import logging
8
+ import pkgutil
9
+ from collections import defaultdict
10
+ from typing import Any
11
+
12
+ from ..base import BaseSearchEngine
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+ # ENGINES[category][name] = class
17
+ ENGINES: dict[str, dict[str, type[BaseSearchEngine[Any]]]] = defaultdict(dict)
18
+
19
+ package_name = __name__
20
+ package = importlib.import_module(package_name)
21
+
22
+ # Auto-discover all search engine classes
23
+ for finder, modname, _ispkg in pkgutil.iter_modules(package.__path__, package_name + "."):
24
+ try:
25
+ module = importlib.import_module(modname)
26
+ for _, cls in inspect.getmembers(module, inspect.isclass):
27
+ # Must subclass BaseSearchEngine (but not the base itself)
28
+ if not issubclass(cls, BaseSearchEngine) or cls is BaseSearchEngine:
29
+ continue
30
+
31
+ # Skip any class whose name starts with "Base"
32
+ if cls.__name__.startswith("Base"):
33
+ continue
34
+
35
+ # Skip disabled engines
36
+ if getattr(cls, "disabled", False):
37
+ logger.info("Skipping disabled engine: %s", cls.name)
38
+ continue
39
+
40
+ # Register the engine
41
+ if hasattr(cls, "name") and hasattr(cls, "category"):
42
+ ENGINES[cls.category][cls.name] = cls
43
+ logger.debug("Registered engine: %s (%s)", cls.name, cls.category)
44
+ except Exception as ex:
45
+ logger.warning("Failed to import module %s: %r", modname, ex)
46
+
47
+
48
+ __all__ = ["ENGINES"]
@@ -0,0 +1,84 @@
1
+ """Bing search engine implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ from collections.abc import Mapping
7
+ from time import time
8
+ from typing import Any
9
+ from urllib.parse import parse_qs, urlparse
10
+
11
+ from ..base import BaseSearchEngine
12
+ from ..results import TextResult
13
+
14
+
15
+ def unwrap_bing_url(raw_url: str) -> str | None:
16
+ """Decode the Bing-wrapped raw_url to extract the original url."""
17
+ try:
18
+ parsed = urlparse(raw_url)
19
+ if parsed.netloc == "www.bing.com" and parsed.path == "/ck/a":
20
+ query_params = parse_qs(parsed.query)
21
+ if "u" in query_params:
22
+ encoded_url = query_params["u"][0]
23
+ # Decode the base64-like encoding
24
+ if encoded_url.startswith("a1"):
25
+ encoded_url = encoded_url[2:]
26
+ # Add padding if needed
27
+ padding = len(encoded_url) % 4
28
+ if padding:
29
+ encoded_url += "=" * (4 - padding)
30
+ try:
31
+ decoded = base64.urlsafe_b64decode(encoded_url).decode()
32
+ return decoded
33
+ except Exception:
34
+ pass
35
+ return raw_url
36
+ except Exception:
37
+ return raw_url
38
+
39
+
40
+ class Bing(BaseSearchEngine[TextResult]):
41
+ """Bing search engine."""
42
+
43
+ name = "bing"
44
+ category = "text"
45
+ provider = "bing"
46
+
47
+ search_url = "https://www.bing.com/search"
48
+ search_method = "GET"
49
+
50
+ items_xpath = "//li[contains(@class, 'b_algo')]"
51
+ elements_xpath: Mapping[str, str] = {
52
+ "title": ".//h2/a//text()",
53
+ "href": ".//h2/a/@href",
54
+ "body": ".//p//text()",
55
+ }
56
+
57
+ def build_payload(
58
+ self, query: str, region: str, safesearch: str, timelimit: str | None, page: int = 1, **kwargs: Any
59
+ ) -> dict[str, Any]:
60
+ """Build a payload for the Bing search request."""
61
+ country, lang = region.lower().split("-")
62
+ payload = {"q": query, "pq": query, "cc": lang}
63
+ cookies = {
64
+ "_EDGE_CD": f"m={lang}-{country}&u={lang}-{country}",
65
+ "_EDGE_S": f"mkt={lang}-{country}&ui={lang}-{country}",
66
+ }
67
+ self.http_client.set_cookies("https://www.bing.com", cookies)
68
+ if timelimit:
69
+ d = int(time() // 86400)
70
+ payload["filters"] = {
71
+ "d": f"ex1:\"ez1_{d - 1}_{d}\"",
72
+ "w": f"ex1:\"ez1_{d - 7}_{d}\"",
73
+ "m": f"ex1:\"ez1_{d - 30}_{d}\"",
74
+ "y": f"ex1:\"ez1_{d - 365}_{d}\"",
75
+ }[timelimit]
76
+ if page > 1:
77
+ payload["first"] = f"{(page - 1) * 10 + 1}"
78
+ return payload
79
+
80
+ def post_extract_results(self, results: list[TextResult]) -> list[TextResult]:
81
+ """Post-process search results."""
82
+ for result in results:
83
+ result.href = unwrap_bing_url(result.href)
84
+ return results
@@ -0,0 +1,52 @@
1
+ """Bing news search engine implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from typing import Any
7
+
8
+ from ..base import BaseSearchEngine
9
+ from ..results import NewsResult
10
+
11
+
12
+ class BingNews(BaseSearchEngine[NewsResult]):
13
+ """Bing news engine."""
14
+
15
+ name = "bing"
16
+ category = "news"
17
+ provider = "bing"
18
+
19
+ search_url = "https://www.bing.com/news/infinitescrollajax"
20
+ search_method = "GET"
21
+
22
+ items_xpath = "//div[contains(@class, 'newsitem')]"
23
+ elements_xpath: Mapping[str, str] = {
24
+ "date": ".//span[@aria-label]//@aria-label",
25
+ "title": "@data-title",
26
+ "body": ".//div[@class='snippet']//text()",
27
+ "url": "@url",
28
+ "image": ".//a[contains(@class, 'image')]//@src",
29
+ "source": "@data-author",
30
+ }
31
+
32
+ def build_payload(
33
+ self, query: str, region: str, safesearch: str, timelimit: str | None, page: int = 1, **kwargs: Any
34
+ ) -> dict[str, Any]:
35
+ """Build a payload for the Bing search request."""
36
+ country, lang = region.lower().split("-")
37
+ payload = {
38
+ "q": query,
39
+ "InfiniteScroll": "1",
40
+ "first": f"{page * 10 + 1}",
41
+ "SFX": f"{page}",
42
+ "cc": country,
43
+ "setlang": lang,
44
+ }
45
+ if timelimit:
46
+ payload["qft"] = {
47
+ "d": 'interval="4"', # doesn't exist so it's the same as one hour
48
+ "w": 'interval="7"',
49
+ "m": 'interval="9"',
50
+ "y": 'interval="9"', # doesn't exist so it's the same as month
51
+ }[timelimit]
52
+ return payload
@@ -0,0 +1,43 @@
1
+ """Brave search engine implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from typing import Any
7
+
8
+ from ..base import BaseSearchEngine
9
+ from ..results import TextResult
10
+
11
+
12
+ class Brave(BaseSearchEngine[TextResult]):
13
+ """Brave search engine."""
14
+
15
+ name = "brave"
16
+ category = "text"
17
+ provider = "brave"
18
+
19
+ search_url = "https://search.brave.com/search"
20
+ search_method = "GET"
21
+
22
+ items_xpath = "//div[@data-type='web']"
23
+ elements_xpath: Mapping[str, str] = {
24
+ "title": ".//div[(contains(@class,'title') or contains(@class,'sitename-container')) and position()=last()]//text()",
25
+ "href": "./a/@href",
26
+ "body": ".//div[contains(@class, 'description')]//text()",
27
+ }
28
+
29
+ def build_payload(
30
+ self, query: str, region: str, safesearch: str, timelimit: str | None, page: int = 1, **kwargs: Any
31
+ ) -> dict[str, Any]:
32
+ """Build a payload for the search request."""
33
+ safesearch_base = {"on": "strict", "moderate": "moderate", "off": "off"}
34
+ payload = {
35
+ "q": query,
36
+ "source": "web",
37
+ "safesearch": safesearch_base[safesearch.lower()],
38
+ }
39
+ if timelimit:
40
+ payload["tf"] = timelimit
41
+ if page > 1:
42
+ payload["offset"] = f"{(page - 1) * 10}"
43
+ return payload
@@ -0,0 +1,25 @@
1
+ """DuckDuckGo search engines package."""
2
+
3
+ from .answers import DuckDuckGoAnswers
4
+ from .base import DuckDuckGoBase
5
+ from .images import DuckDuckGoImages
6
+ from .maps import DuckDuckGoMaps
7
+ from .news import DuckDuckGoNews
8
+ from .suggestions import DuckDuckGoSuggestions
9
+ from .text import DuckDuckGoTextSearch
10
+ from .translate import DuckDuckGoTranslate
11
+ from .videos import DuckDuckGoVideos
12
+ from .weather import DuckDuckGoWeather
13
+
14
+ __all__ = [
15
+ "DuckDuckGoBase",
16
+ "DuckDuckGoTextSearch",
17
+ "DuckDuckGoImages",
18
+ "DuckDuckGoVideos",
19
+ "DuckDuckGoNews",
20
+ "DuckDuckGoAnswers",
21
+ "DuckDuckGoSuggestions",
22
+ "DuckDuckGoMaps",
23
+ "DuckDuckGoTranslate",
24
+ "DuckDuckGoWeather",
25
+ ]
@@ -0,0 +1,78 @@
1
+ """DuckDuckGo answers search."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from ....exceptions import WebscoutE
6
+ from .base import DuckDuckGoBase
7
+
8
+
9
+ class DuckDuckGoAnswers(DuckDuckGoBase):
10
+ """DuckDuckGo instant answers."""
11
+
12
+ def run(self, *args, **kwargs) -> list[dict[str, str]]:
13
+ """Get instant answers from DuckDuckGo.
14
+
15
+ Args:
16
+ keywords: Search query.
17
+
18
+ Returns:
19
+ List of answer dictionaries.
20
+ """
21
+ keywords = args[0] if args else kwargs.get("keywords")
22
+
23
+ assert keywords, "keywords is mandatory"
24
+
25
+ payload = {
26
+ "q": f"what is {keywords}",
27
+ "format": "json",
28
+ }
29
+ resp_content = self._get_url("GET", "https://api.duckduckgo.com/", params=payload).content
30
+ page_data = self.json_loads(resp_content)
31
+
32
+ results = []
33
+ answer = page_data.get("AbstractText")
34
+ url = page_data.get("AbstractURL")
35
+ if answer:
36
+ results.append(
37
+ {
38
+ "icon": None,
39
+ "text": answer,
40
+ "topic": None,
41
+ "url": url,
42
+ }
43
+ )
44
+
45
+ # related
46
+ payload = {
47
+ "q": f"{keywords}",
48
+ "format": "json",
49
+ }
50
+ resp_content = self._get_url("GET", "https://api.duckduckgo.com/", params=payload).content
51
+ resp_json = self.json_loads(resp_content)
52
+ page_data = resp_json.get("RelatedTopics", [])
53
+
54
+ for row in page_data:
55
+ topic = row.get("Name")
56
+ if not topic:
57
+ icon = row["Icon"].get("URL")
58
+ results.append(
59
+ {
60
+ "icon": f"https://duckduckgo.com{icon}" if icon else "",
61
+ "text": row["Text"],
62
+ "topic": None,
63
+ "url": row["FirstURL"],
64
+ }
65
+ )
66
+ else:
67
+ for subrow in row["Topics"]:
68
+ icon = subrow["Icon"].get("URL")
69
+ results.append(
70
+ {
71
+ "icon": f"https://duckduckgo.com{icon}" if icon else "",
72
+ "text": subrow["Text"],
73
+ "topic": topic,
74
+ "url": subrow["FirstURL"],
75
+ }
76
+ )
77
+
78
+ return results
@@ -0,0 +1,187 @@
1
+ """Base class for DuckDuckGo search implementations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from concurrent.futures import ThreadPoolExecutor
7
+ from functools import cached_property
8
+ from itertools import cycle, islice
9
+ from random import choice
10
+ from time import sleep, time
11
+ from typing import Any
12
+
13
+ try:
14
+ import trio
15
+ except ImportError:
16
+ pass
17
+
18
+ import curl_cffi.requests
19
+
20
+ try:
21
+ from lxml.html import HTMLParser as LHTMLParser
22
+ from lxml.html import document_fromstring
23
+ LXML_AVAILABLE = True
24
+ except ImportError:
25
+ LXML_AVAILABLE = False
26
+
27
+ from ....exceptions import RatelimitE, TimeoutE, WebscoutE
28
+ from ....utils import (
29
+ _extract_vqd,
30
+ _normalize,
31
+ _normalize_url,
32
+ json_loads,
33
+ )
34
+ from ....litagent import LitAgent
35
+
36
+
37
+ class DuckDuckGoBase:
38
+ """Base class for DuckDuckGo search operations."""
39
+
40
+ _executor: ThreadPoolExecutor = ThreadPoolExecutor()
41
+ _impersonates = (
42
+ "chrome99", "chrome100", "chrome101", "chrome104", "chrome107", "chrome110",
43
+ "chrome116", "chrome119", "chrome120", "chrome123", "chrome124", "chrome131", "chrome133a",
44
+ "chrome99_android", "chrome131_android",
45
+ "safari15_3", "safari15_5", "safari17_0", "safari17_2_ios", "safari18_0", "safari18_0_ios",
46
+ "edge99", "edge101",
47
+ "firefox133", "firefox135",
48
+ )
49
+
50
+ def __init__(
51
+ self,
52
+ headers: dict[str, str] | None = None,
53
+ proxy: str | None = None,
54
+ proxies: dict[str, str] | str | None = None,
55
+ timeout: int | None = 10,
56
+ verify: bool = True,
57
+ ) -> None:
58
+ """Initialize DuckDuckGo base client.
59
+
60
+ Args:
61
+ headers: Dictionary of headers for the HTTP client.
62
+ proxy: Proxy for the HTTP client (http/https/socks5).
63
+ proxies: Deprecated, use proxy instead.
64
+ timeout: Timeout value for the HTTP client.
65
+ verify: SSL verification when making requests.
66
+ """
67
+ ddgs_proxy: str | None = os.environ.get("DDGS_PROXY")
68
+ self.proxy: str | None = ddgs_proxy if ddgs_proxy else proxy
69
+
70
+ if not proxy and proxies:
71
+ self.proxy = proxies.get("http") or proxies.get("https") if isinstance(proxies, dict) else proxies
72
+
73
+ default_headers = {
74
+ **LitAgent().generate_fingerprint(),
75
+ "Origin": "https://duckduckgo.com",
76
+ "Referer": "https://duckduckgo.com/",
77
+ }
78
+
79
+ self.headers = headers if headers else {}
80
+ self.headers.update(default_headers)
81
+
82
+ impersonate_browser = choice(self._impersonates)
83
+ self.client = curl_cffi.requests.Session(
84
+ headers=self.headers,
85
+ proxies={'http': self.proxy, 'https': self.proxy} if self.proxy else None,
86
+ timeout=timeout,
87
+ impersonate=impersonate_browser,
88
+ verify=verify,
89
+ )
90
+ self.timeout = timeout
91
+ self.sleep_timestamp = 0.0
92
+
93
+ # Utility methods
94
+ self.cycle = cycle
95
+ self.islice = islice
96
+
97
+ @cached_property
98
+ def parser(self) -> Any:
99
+ """Get HTML parser."""
100
+ if not LXML_AVAILABLE:
101
+ raise ImportError("lxml is required for HTML parsing")
102
+
103
+ class Parser:
104
+ def __init__(self):
105
+ self.lhtml_parser = LHTMLParser(
106
+ remove_blank_text=True,
107
+ remove_comments=True,
108
+ remove_pis=True,
109
+ collect_ids=False
110
+ )
111
+ self.etree = __import__('lxml.etree', fromlist=['Element'])
112
+
113
+ def fromstring(self, html: bytes | str) -> Any:
114
+ return document_fromstring(html, parser=self.lhtml_parser)
115
+
116
+ return Parser()
117
+
118
+ def _sleep(self, sleeptime: float = 0.75) -> None:
119
+ """Sleep between API requests."""
120
+ delay = 0.0 if not self.sleep_timestamp else 0.0 if time() - self.sleep_timestamp >= 20 else sleeptime
121
+ self.sleep_timestamp = time()
122
+ sleep(delay)
123
+
124
+ def _get_url(
125
+ self,
126
+ method: str,
127
+ url: str,
128
+ params: dict[str, str] | None = None,
129
+ content: bytes | None = None,
130
+ data: dict[str, str] | None = None,
131
+ headers: dict[str, str] | None = None,
132
+ cookies: dict[str, str] | None = None,
133
+ json: Any = None,
134
+ timeout: float | None = None,
135
+ ) -> Any:
136
+ """Make HTTP request."""
137
+ self._sleep()
138
+ try:
139
+ request_kwargs = {
140
+ "params": params,
141
+ "headers": headers,
142
+ "json": json,
143
+ "timeout": timeout or self.timeout,
144
+ }
145
+
146
+ if isinstance(cookies, dict):
147
+ request_kwargs["cookies"] = cookies
148
+
149
+ if method == "GET":
150
+ if content:
151
+ request_kwargs["data"] = content
152
+ resp = self.client.get(url, **request_kwargs)
153
+ elif method == "POST":
154
+ if data or content:
155
+ request_kwargs["data"] = data or content
156
+ resp = self.client.post(url, **request_kwargs)
157
+ else:
158
+ if data or content:
159
+ request_kwargs["data"] = data or content
160
+ resp = self.client.request(method, url, **request_kwargs)
161
+ except Exception as ex:
162
+ if "time" in str(ex).lower():
163
+ raise TimeoutE(f"{url} {type(ex).__name__}: {ex}") from ex
164
+ raise WebscoutE(f"{url} {type(ex).__name__}: {ex}") from ex
165
+
166
+ if resp.status_code == 200:
167
+ return resp
168
+ elif resp.status_code in (202, 301, 403, 400, 429, 418):
169
+ raise RatelimitE(f"{resp.url} {resp.status_code} Ratelimit")
170
+ raise WebscoutE(f"{resp.url} return None. {params=} {content=} {data=}")
171
+
172
+ def _get_vqd(self, keywords: str) -> str:
173
+ """Get vqd value for a search query."""
174
+ resp_content = self._get_url("GET", "https://duckduckgo.com", params={"q": keywords}).content
175
+ return _extract_vqd(resp_content, keywords)
176
+
177
+ def json_loads(self, obj: str | bytes) -> Any:
178
+ """Load JSON from string or bytes."""
179
+ return json_loads(obj)
180
+
181
+ def _normalize(self, text: str) -> str:
182
+ """Normalize text."""
183
+ return _normalize(text)
184
+
185
+ def _normalize_url(self, url: str) -> str:
186
+ """Normalize URL."""
187
+ return _normalize_url(url)
@@ -0,0 +1,97 @@
1
+ """DuckDuckGo image search."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from ....exceptions import WebscoutE
6
+ from .base import DuckDuckGoBase
7
+
8
+
9
+ class DuckDuckGoImages(DuckDuckGoBase):
10
+ """DuckDuckGo image search."""
11
+
12
+ def run(self, *args, **kwargs) -> list[dict[str, str]]:
13
+ """Perform image search on DuckDuckGo.
14
+
15
+ Args:
16
+ keywords: Search query.
17
+ region: Region code.
18
+ safesearch: on, moderate, or off.
19
+ timelimit: d, w, m, or y.
20
+ size: Small, Medium, Large, Wallpaper.
21
+ color: color name or Monochrome.
22
+ type_image: photo, clipart, gif, transparent, line.
23
+ layout: Square, Tall, Wide.
24
+ license_image: any, Public, Share, etc.
25
+ max_results: Maximum number of results.
26
+
27
+ Returns:
28
+ List of image result dictionaries.
29
+ """
30
+ keywords = args[0] if args else kwargs.get("keywords")
31
+ region = args[1] if len(args) > 1 else kwargs.get("region", "wt-wt")
32
+ safesearch = args[2] if len(args) > 2 else kwargs.get("safesearch", "moderate")
33
+ timelimit = args[3] if len(args) > 3 else kwargs.get("timelimit")
34
+ size = args[4] if len(args) > 4 else kwargs.get("size")
35
+ color = args[5] if len(args) > 5 else kwargs.get("color")
36
+ type_image = args[6] if len(args) > 6 else kwargs.get("type_image")
37
+ layout = args[7] if len(args) > 7 else kwargs.get("layout")
38
+ license_image = args[8] if len(args) > 8 else kwargs.get("license_image")
39
+ max_results = args[9] if len(args) > 9 else kwargs.get("max_results")
40
+
41
+ assert keywords, "keywords is mandatory"
42
+
43
+ vqd = self._get_vqd(keywords)
44
+
45
+ safesearch_base = {"on": "1", "moderate": "1", "off": "-1"}
46
+ timelimit = f"time:{timelimit}" if timelimit else ""
47
+ size = f"size:{size}" if size else ""
48
+ color = f"color:{color}" if color else ""
49
+ type_image = f"type:{type_image}" if type_image else ""
50
+ layout = f"layout:{layout}" if layout else ""
51
+ license_image = f"license:{license_image}" if license_image else ""
52
+ payload = {
53
+ "l": region,
54
+ "o": "json",
55
+ "q": keywords,
56
+ "vqd": vqd,
57
+ "f": f"{timelimit},{size},{color},{type_image},{layout},{license_image}",
58
+ "p": safesearch_base[safesearch.lower()],
59
+ }
60
+
61
+ cache = set()
62
+ results: list[dict[str, str]] = []
63
+
64
+ def _images_page(s: int) -> list[dict[str, str]]:
65
+ payload["s"] = f"{s}"
66
+ resp_content = self._get_url("GET", "https://duckduckgo.com/i.js", params=payload).content
67
+ resp_json = self.json_loads(resp_content)
68
+
69
+ page_data = resp_json.get("results", [])
70
+ page_results = []
71
+ for row in page_data:
72
+ image_url = row.get("image")
73
+ if image_url and image_url not in cache:
74
+ cache.add(image_url)
75
+ result = {
76
+ "title": row["title"],
77
+ "image": self._normalize_url(image_url),
78
+ "thumbnail": self._normalize_url(row["thumbnail"]),
79
+ "url": self._normalize_url(row["url"]),
80
+ "height": row["height"],
81
+ "width": row["width"],
82
+ "source": row["source"],
83
+ }
84
+ page_results.append(result)
85
+ return page_results
86
+
87
+ slist = [0]
88
+ if max_results:
89
+ max_results = min(max_results, 500)
90
+ slist.extend(range(100, max_results, 100))
91
+ try:
92
+ for r in self._executor.map(_images_page, slist):
93
+ results.extend(r)
94
+ except Exception as e:
95
+ raise e
96
+
97
+ return list(self.islice(results, max_results))