webscout 6.2b0__py3-none-any.whl → 6.4__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/AIauto.py +191 -176
- webscout/AIbase.py +112 -239
- webscout/AIutel.py +488 -1130
- webscout/Agents/functioncall.py +248 -198
- webscout/Bing_search.py +250 -153
- webscout/DWEBS.py +454 -178
- webscout/Extra/__init__.py +2 -1
- webscout/Extra/autocoder/__init__.py +9 -0
- webscout/Extra/autocoder/autocoder_utiles.py +121 -0
- webscout/Extra/autocoder/rawdog.py +681 -0
- webscout/Extra/autollama.py +246 -195
- webscout/Extra/gguf.py +441 -226
- webscout/Extra/weather.py +172 -67
- webscout/LLM.py +442 -100
- webscout/Litlogger/__init__.py +681 -0
- webscout/Local/formats.py +4 -2
- webscout/Provider/Amigo.py +19 -10
- webscout/Provider/Andi.py +0 -33
- webscout/Provider/Blackboxai.py +4 -204
- webscout/Provider/DARKAI.py +1 -1
- webscout/Provider/EDITEE.py +1 -1
- webscout/Provider/Llama3.py +1 -1
- webscout/Provider/Marcus.py +137 -0
- webscout/Provider/NinjaChat.py +1 -1
- webscout/Provider/PI.py +221 -207
- webscout/Provider/Perplexity.py +598 -598
- webscout/Provider/RoboCoders.py +206 -0
- webscout/Provider/TTI/AiForce/__init__.py +22 -0
- webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
- webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
- webscout/Provider/TTI/Nexra/__init__.py +22 -0
- webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
- webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
- webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
- webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
- webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
- webscout/Provider/TTI/__init__.py +3 -4
- webscout/Provider/TTI/artbit/__init__.py +22 -0
- webscout/Provider/TTI/artbit/async_artbit.py +184 -0
- webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
- webscout/Provider/TTI/blackbox/__init__.py +4 -0
- webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
- webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
- webscout/Provider/TTI/deepinfra/__init__.py +4 -0
- webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
- webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
- webscout/Provider/TTI/huggingface/__init__.py +22 -0
- webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
- webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
- webscout/Provider/TTI/imgninza/__init__.py +4 -0
- webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
- webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
- webscout/Provider/TTI/talkai/__init__.py +4 -0
- webscout/Provider/TTI/talkai/async_talkai.py +229 -0
- webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
- webscout/Provider/__init__.py +146 -132
- webscout/Provider/askmyai.py +158 -0
- webscout/Provider/cerebras.py +227 -206
- webscout/Provider/geminiapi.py +208 -198
- webscout/Provider/llama3mitril.py +180 -0
- webscout/Provider/llmchat.py +203 -0
- webscout/Provider/mhystical.py +176 -0
- webscout/Provider/perplexitylabs.py +265 -0
- webscout/Provider/talkai.py +196 -0
- webscout/Provider/twitterclone.py +251 -244
- webscout/Provider/typegpt.py +359 -0
- webscout/__init__.py +28 -23
- webscout/__main__.py +5 -5
- webscout/cli.py +327 -347
- webscout/conversation.py +227 -0
- webscout/exceptions.py +161 -29
- webscout/litagent/__init__.py +172 -0
- webscout/litprinter/__init__.py +831 -0
- webscout/optimizers.py +270 -0
- webscout/prompt_manager.py +279 -0
- webscout/swiftcli/__init__.py +810 -0
- webscout/transcriber.py +479 -551
- webscout/update_checker.py +125 -0
- webscout/version.py +1 -1
- webscout-6.4.dist-info/LICENSE.md +211 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/METADATA +34 -55
- webscout-6.4.dist-info/RECORD +154 -0
- webscout/Provider/TTI/AIuncensored.py +0 -103
- webscout/Provider/TTI/Nexra.py +0 -120
- webscout/Provider/TTI/PollinationsAI.py +0 -138
- webscout/Provider/TTI/WebSimAI.py +0 -142
- webscout/Provider/TTI/aiforce.py +0 -160
- webscout/Provider/TTI/artbit.py +0 -141
- webscout/Provider/TTI/deepinfra.py +0 -148
- webscout/Provider/TTI/huggingface.py +0 -155
- webscout/models.py +0 -23
- webscout-6.2b0.dist-info/LICENSE.md +0 -50
- webscout-6.2b0.dist-info/RECORD +0 -118
- /webscout/{g4f.py → gpt4free.py} +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
- {webscout-6.2b0.dist-info → webscout-6.4.dist-info}/top_level.txt +0 -0
webscout/Bing_search.py
CHANGED
|
@@ -1,154 +1,251 @@
|
|
|
1
|
-
from bs4 import BeautifulSoup
|
|
2
|
-
import requests
|
|
3
|
-
from typing import Dict, List, Optional, Union
|
|
4
|
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
5
|
-
from urllib.parse import quote, urlparse, parse_qs
|
|
6
|
-
import base64
|
|
7
|
-
import urllib3
|
|
8
|
-
|
|
9
|
-
# Disable SSL warnings
|
|
10
|
-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
11
|
-
|
|
12
|
-
class BingS:
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
1
|
+
from bs4 import BeautifulSoup
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Dict, List, Optional, Union
|
|
4
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
5
|
+
from urllib.parse import quote, urlparse, parse_qs
|
|
6
|
+
import base64
|
|
7
|
+
import urllib3
|
|
8
|
+
|
|
9
|
+
# Disable SSL warnings
|
|
10
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
11
|
+
|
|
12
|
+
class BingS:
|
|
13
|
+
"""A Python interface for Bing search engine.
|
|
14
|
+
|
|
15
|
+
The BingS class provides a simple interface to perform searches on Bing.com
|
|
16
|
+
and extract search results programmatically.
|
|
17
|
+
|
|
18
|
+
Basic Usage:
|
|
19
|
+
>>> from webscout.Bing_search import BingS
|
|
20
|
+
>>> searcher = BingS()
|
|
21
|
+
>>> results = searcher.search("Python programming")
|
|
22
|
+
>>> for result in results:
|
|
23
|
+
... print(result['title'], result['href'])
|
|
24
|
+
|
|
25
|
+
Advanced Usage:
|
|
26
|
+
>>> # With custom headers and proxy
|
|
27
|
+
>>> headers = {'User-Agent': 'Custom User Agent'}
|
|
28
|
+
>>> proxy = 'http://proxy.example.com:8080'
|
|
29
|
+
>>> searcher = BingS(headers=headers, proxy=proxy)
|
|
30
|
+
>>> results = searcher.search(
|
|
31
|
+
... "AI developments",
|
|
32
|
+
... max_results=5,
|
|
33
|
+
... extract_webpage_text=True,
|
|
34
|
+
... max_extract_characters=1000
|
|
35
|
+
... )
|
|
36
|
+
>>> # Access result fields
|
|
37
|
+
>>> for result in results:
|
|
38
|
+
... print(f"Title: {result['title']}")
|
|
39
|
+
... print(f"URL: {result['href']}")
|
|
40
|
+
... print(f"Description: {result['abstract']}")
|
|
41
|
+
... if result['visible_text']:
|
|
42
|
+
... print(f"Page Content: {result['visible_text'][:100]}...")
|
|
43
|
+
|
|
44
|
+
The class supports context management protocol:
|
|
45
|
+
>>> with BingS() as searcher:
|
|
46
|
+
... results = searcher.search("Python tutorials")
|
|
47
|
+
|
|
48
|
+
Return Dictionary Format:
|
|
49
|
+
{
|
|
50
|
+
'title': str, # The title of the search result
|
|
51
|
+
'href': str, # The URL of the search result
|
|
52
|
+
'abstract': str, # Brief description or snippet
|
|
53
|
+
'index': int, # Position in search results
|
|
54
|
+
'type': str, # Type of result (always 'web')
|
|
55
|
+
'visible_text': str # Extracted webpage text (if requested)
|
|
56
|
+
}
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
_executor: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=10)
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
headers: Optional[Dict[str, str]] = None,
|
|
64
|
+
proxy: Optional[str] = None,
|
|
65
|
+
timeout: Optional[int] = 10,
|
|
66
|
+
) -> None:
|
|
67
|
+
"""Initialize a new BingS instance.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
headers (Optional[Dict[str, str]]): Custom HTTP headers for requests.
|
|
71
|
+
Defaults to a standard User-Agent if not provided.
|
|
72
|
+
proxy (Optional[str]): Proxy URL to use for requests.
|
|
73
|
+
Example: 'http://proxy.example.com:8080'
|
|
74
|
+
timeout (Optional[int]): Request timeout in seconds. Defaults to 10.
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
>>> searcher = BingS(
|
|
78
|
+
... headers={'User-Agent': 'Custom UA'},
|
|
79
|
+
... proxy='http://proxy.example.com:8080',
|
|
80
|
+
... timeout=15
|
|
81
|
+
... )
|
|
82
|
+
"""
|
|
83
|
+
self.proxy: Optional[str] = proxy
|
|
84
|
+
self.headers = headers if headers else {
|
|
85
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
86
|
+
}
|
|
87
|
+
self.headers["Referer"] = "https://www.bing.com/"
|
|
88
|
+
self.client = requests.Session()
|
|
89
|
+
self.client.headers.update(self.headers)
|
|
90
|
+
self.client.proxies.update({"http": self.proxy, "https": self.proxy})
|
|
91
|
+
self.timeout = timeout
|
|
92
|
+
|
|
93
|
+
def __enter__(self) -> "BingS":
|
|
94
|
+
return self
|
|
95
|
+
|
|
96
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
97
|
+
self.client.close()
|
|
98
|
+
|
|
99
|
+
def _get_url(
|
|
100
|
+
self,
|
|
101
|
+
method: str,
|
|
102
|
+
url: str,
|
|
103
|
+
params: Optional[Dict[str, str]] = None,
|
|
104
|
+
data: Optional[Union[Dict[str, str], bytes]] = None,
|
|
105
|
+
) -> bytes:
|
|
106
|
+
try:
|
|
107
|
+
resp = self.client.request(method, url, params=params, data=data, timeout=self.timeout, verify=False)
|
|
108
|
+
except Exception as ex:
|
|
109
|
+
raise Exception(f"{url} {type(ex).__name__}: {ex}") from ex
|
|
110
|
+
if resp.status_code == 200:
|
|
111
|
+
return resp.content
|
|
112
|
+
raise Exception(f"{resp.url} returned status code {resp.status_code}. {params=} {data=}")
|
|
113
|
+
|
|
114
|
+
def extract_text_from_webpage(self, html_content, max_characters=None):
|
|
115
|
+
"""Extracts visible text from HTML content using BeautifulSoup."""
|
|
116
|
+
soup = BeautifulSoup(html_content, "html.parser")
|
|
117
|
+
# Remove unwanted tags
|
|
118
|
+
for tag in soup(["script", "style", "header", "footer", "nav"]):
|
|
119
|
+
tag.extract()
|
|
120
|
+
# Get the remaining visible text
|
|
121
|
+
visible_text = soup.get_text(separator=' ', strip=True)
|
|
122
|
+
if max_characters:
|
|
123
|
+
visible_text = visible_text[:max_characters]
|
|
124
|
+
return visible_text
|
|
125
|
+
|
|
126
|
+
def search(
|
|
127
|
+
self,
|
|
128
|
+
keywords: str,
|
|
129
|
+
max_results: Optional[int] = 10,
|
|
130
|
+
extract_webpage_text: bool = False,
|
|
131
|
+
max_extract_characters: Optional[int] = 100,
|
|
132
|
+
) -> List[Dict[str, str]]:
|
|
133
|
+
"""Perform a Bing search and return results.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
keywords (str): Search query string.
|
|
137
|
+
max_results (Optional[int]): Maximum number of results to return.
|
|
138
|
+
Defaults to 10.
|
|
139
|
+
extract_webpage_text (bool): If True, fetches and extracts text from
|
|
140
|
+
each result webpage. Defaults to False.
|
|
141
|
+
max_extract_characters (Optional[int]): Maximum number of characters
|
|
142
|
+
to extract from each webpage. Only used if extract_webpage_text
|
|
143
|
+
is True. Defaults to 100.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
List[Dict[str, str]]: List of search results. Each result contains:
|
|
147
|
+
- title: The title of the search result
|
|
148
|
+
- href: The URL of the search result
|
|
149
|
+
- abstract: Brief description or snippet
|
|
150
|
+
- index: Position in search results
|
|
151
|
+
- type: Type of result (always 'web')
|
|
152
|
+
- visible_text: Extracted webpage text (if extract_webpage_text=True)
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
AssertionError: If keywords is empty.
|
|
156
|
+
Exception: If request fails or returns non-200 status code.
|
|
157
|
+
|
|
158
|
+
Example:
|
|
159
|
+
>>> searcher = BingS()
|
|
160
|
+
>>> results = searcher.search(
|
|
161
|
+
... "Python tutorials",
|
|
162
|
+
... max_results=5,
|
|
163
|
+
... extract_webpage_text=True
|
|
164
|
+
... )
|
|
165
|
+
>>> for result in results:
|
|
166
|
+
... print(f"Title: {result['title']}")
|
|
167
|
+
... print(f"URL: {result['href']}")
|
|
168
|
+
... print(f"Description: {result['abstract']}")
|
|
169
|
+
... if result['visible_text']:
|
|
170
|
+
... print(f"Content: {result['visible_text'][:100]}...")
|
|
171
|
+
"""
|
|
172
|
+
assert keywords, "keywords is mandatory"
|
|
173
|
+
|
|
174
|
+
results = []
|
|
175
|
+
futures = []
|
|
176
|
+
start = 1
|
|
177
|
+
while len(results) < max_results:
|
|
178
|
+
params = {
|
|
179
|
+
"q": keywords,
|
|
180
|
+
"first": start
|
|
181
|
+
}
|
|
182
|
+
futures.append(self._executor.submit(self._get_url, "GET", "https://www.bing.com/search", params=params))
|
|
183
|
+
start += 10
|
|
184
|
+
|
|
185
|
+
for future in as_completed(futures):
|
|
186
|
+
try:
|
|
187
|
+
resp_content = future.result()
|
|
188
|
+
soup = BeautifulSoup(resp_content, "html.parser")
|
|
189
|
+
result_block = soup.select('li.b_algo')
|
|
190
|
+
|
|
191
|
+
if not result_block:
|
|
192
|
+
break
|
|
193
|
+
|
|
194
|
+
for result in result_block:
|
|
195
|
+
try:
|
|
196
|
+
link = result.select_one('h2 a')
|
|
197
|
+
title = link.text if link else ""
|
|
198
|
+
url = link['href'] if link else ""
|
|
199
|
+
abstract = result.select_one('.b_caption p')
|
|
200
|
+
description = abstract.text if abstract else ""
|
|
201
|
+
|
|
202
|
+
# Remove "WEB" from the beginning of the description if it exists
|
|
203
|
+
if description.startswith("WEB"):
|
|
204
|
+
description = description[3:].strip()
|
|
205
|
+
|
|
206
|
+
visible_text = ""
|
|
207
|
+
if extract_webpage_text:
|
|
208
|
+
try:
|
|
209
|
+
actual_url = self._decode_bing_url(url)
|
|
210
|
+
page_content = self._get_url("GET", actual_url)
|
|
211
|
+
visible_text = self.extract_text_from_webpage(
|
|
212
|
+
page_content, max_characters=max_extract_characters
|
|
213
|
+
)
|
|
214
|
+
except Exception as e:
|
|
215
|
+
print(f"Error extracting text from {url}: {e}")
|
|
216
|
+
|
|
217
|
+
results.append({
|
|
218
|
+
"title": title,
|
|
219
|
+
"href": url,
|
|
220
|
+
"abstract": description,
|
|
221
|
+
"index": len(results),
|
|
222
|
+
"type": "web",
|
|
223
|
+
"visible_text": visible_text,
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
if len(results) >= max_results:
|
|
227
|
+
return results
|
|
228
|
+
|
|
229
|
+
except Exception as e:
|
|
230
|
+
print(f"Error extracting result: {e}")
|
|
231
|
+
|
|
232
|
+
except Exception as e:
|
|
233
|
+
print(f"Error fetching URL: {e}")
|
|
234
|
+
|
|
235
|
+
return results
|
|
236
|
+
|
|
237
|
+
def _decode_bing_url(self, url):
|
|
238
|
+
if 'bing.com/ck/a' in url:
|
|
239
|
+
parsed_url = urlparse(url)
|
|
240
|
+
query_params = parse_qs(parsed_url.query)
|
|
241
|
+
if 'u' in query_params:
|
|
242
|
+
encoded_url = query_params['u'][0]
|
|
243
|
+
return base64.b64decode(encoded_url).decode('utf-8')
|
|
244
|
+
return url
|
|
245
|
+
|
|
246
|
+
if __name__ == "__main__":
|
|
247
|
+
from rich import print
|
|
248
|
+
searcher = BingS()
|
|
249
|
+
results = searcher.search("Python development tools", max_results=5, extract_webpage_text=True, max_extract_characters=2000)
|
|
250
|
+
for result in results:
|
|
154
251
|
print(result)
|