webscout 1.0.2__py3-none-any.whl → 1.0.5__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/__init__.py +6 -6
- webscout/__main__.py +1 -1
- webscout/cli.py +10 -10
- webscout/exceptions.py +1 -1
- webscout/utils.py +3 -3
- webscout/version.py +1 -1
- webscout/webscout_search.py +7 -4
- webscout/webscout_search_async.py +11 -10
- {webscout-1.0.2.dist-info → webscout-1.0.5.dist-info}/METADATA +92 -102
- webscout-1.0.5.dist-info/RECORD +15 -0
- webscout-1.0.5.dist-info/entry_points.txt +2 -0
- webscout-1.0.2.dist-info/RECORD +0 -15
- webscout-1.0.2.dist-info/entry_points.txt +0 -2
- {webscout-1.0.2.dist-info → webscout-1.0.5.dist-info}/LICENSE.md +0 -0
- {webscout-1.0.2.dist-info → webscout-1.0.5.dist-info}/WHEEL +0 -0
- {webscout-1.0.2.dist-info → webscout-1.0.5.dist-info}/top_level.txt +0 -0
webscout/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Webscout.
|
|
2
2
|
|
|
3
3
|
Search for words, documents, images, videos, news, maps and text translation
|
|
4
4
|
using the DuckDuckGo.com search engine.
|
|
@@ -6,13 +6,13 @@ using the DuckDuckGo.com search engine.
|
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
|
|
9
|
-
#
|
|
10
|
-
from .webscout_search import
|
|
11
|
-
from .webscout_search_async import
|
|
9
|
+
# ruff: noqa: F401
|
|
10
|
+
from .webscout_search import WEBS
|
|
11
|
+
from .webscout_search_async import AsyncWEBS
|
|
12
12
|
from .version import __version__
|
|
13
13
|
|
|
14
|
-
__all__ = ["
|
|
14
|
+
__all__ = ["WEBS", "AsyncWEBS", "__version__", "cli"]
|
|
15
15
|
|
|
16
16
|
# A do-nothing logging handler
|
|
17
17
|
# https://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library
|
|
18
|
-
logging.getLogger("
|
|
18
|
+
logging.getLogger("webscout").addHandler(logging.NullHandler())
|
webscout/__main__.py
CHANGED
webscout/cli.py
CHANGED
|
@@ -9,7 +9,7 @@ from urllib.parse import unquote
|
|
|
9
9
|
import click
|
|
10
10
|
from curl_cffi import requests
|
|
11
11
|
|
|
12
|
-
from .webscout_search import
|
|
12
|
+
from .webscout_search import WEBS
|
|
13
13
|
from .version import __version__
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger(__name__)
|
|
@@ -144,7 +144,7 @@ def version():
|
|
|
144
144
|
def text(keywords, region, safesearch, timelimit, backend, output, download, threads, max_results, proxy):
|
|
145
145
|
"""CLI function to perform a text search using DuckDuckGo API."""
|
|
146
146
|
data = []
|
|
147
|
-
for r in
|
|
147
|
+
for r in WEBS(proxies=proxy).text(
|
|
148
148
|
keywords=keywords,
|
|
149
149
|
region=region,
|
|
150
150
|
safesearch=safesearch,
|
|
@@ -172,7 +172,7 @@ def text(keywords, region, safesearch, timelimit, backend, output, download, thr
|
|
|
172
172
|
def answers(keywords, output, proxy):
|
|
173
173
|
"""CLI function to perform a answers search using DuckDuckGo API."""
|
|
174
174
|
data = []
|
|
175
|
-
for r in
|
|
175
|
+
for r in WEBS(proxies=proxy).answers(keywords=keywords):
|
|
176
176
|
data.append(r)
|
|
177
177
|
filename = f"answers_{_sanitize_keywords(keywords)}_{datetime.now():%Y%m%d_%H%M%S}"
|
|
178
178
|
if output == "print":
|
|
@@ -245,7 +245,7 @@ def images(
|
|
|
245
245
|
):
|
|
246
246
|
"""CLI function to perform a images search using DuckDuckGo API."""
|
|
247
247
|
data = []
|
|
248
|
-
for r in
|
|
248
|
+
for r in WEBS(proxies=proxy).images(
|
|
249
249
|
keywords=keywords,
|
|
250
250
|
region=region,
|
|
251
251
|
safesearch=safesearch,
|
|
@@ -284,7 +284,7 @@ def images(
|
|
|
284
284
|
def videos(keywords, region, safesearch, timelimit, resolution, duration, license_videos, max_results, output, proxy):
|
|
285
285
|
"""CLI function to perform a videos search using DuckDuckGo API."""
|
|
286
286
|
data = []
|
|
287
|
-
for r in
|
|
287
|
+
for r in WEBS(proxies=proxy).videos(
|
|
288
288
|
keywords=keywords,
|
|
289
289
|
region=region,
|
|
290
290
|
safesearch=safesearch,
|
|
@@ -315,7 +315,7 @@ def videos(keywords, region, safesearch, timelimit, resolution, duration, licens
|
|
|
315
315
|
def news(keywords, region, safesearch, timelimit, max_results, output, proxy):
|
|
316
316
|
"""CLI function to perform a news search using DuckDuckGo API."""
|
|
317
317
|
data = []
|
|
318
|
-
for r in
|
|
318
|
+
for r in WEBS(proxies=proxy).news(
|
|
319
319
|
keywords=keywords, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results
|
|
320
320
|
):
|
|
321
321
|
data.append(r)
|
|
@@ -362,7 +362,7 @@ def maps(
|
|
|
362
362
|
"""CLI function to perform a maps search using DuckDuckGo API."""
|
|
363
363
|
data = []
|
|
364
364
|
for i, r in enumerate(
|
|
365
|
-
|
|
365
|
+
WEBS(proxies=proxy).maps(
|
|
366
366
|
keywords=keywords,
|
|
367
367
|
place=place,
|
|
368
368
|
street=street,
|
|
@@ -398,7 +398,7 @@ def maps(
|
|
|
398
398
|
@click.option("-p", "--proxy", default=None, help="the proxy to send requests, example: socks5://localhost:9150")
|
|
399
399
|
def translate(keywords, from_, to, output, proxy):
|
|
400
400
|
"""CLI function to perform translate using DuckDuckGo API."""
|
|
401
|
-
data =
|
|
401
|
+
data = WEBS(proxies=proxy).translate(keywords=keywords, from_=from_, to=to)
|
|
402
402
|
data = [data]
|
|
403
403
|
filename = f"translate_{_sanitize_keywords(keywords)}_{datetime.now():%Y%m%d_%H%M%S}"
|
|
404
404
|
if output == "print":
|
|
@@ -417,7 +417,7 @@ def translate(keywords, from_, to, output, proxy):
|
|
|
417
417
|
def suggestions(keywords, region, output, proxy):
|
|
418
418
|
"""CLI function to perform a suggestions search using DuckDuckGo API."""
|
|
419
419
|
data = []
|
|
420
|
-
for r in
|
|
420
|
+
for r in WEBS(proxies=proxy).suggestions(keywords=keywords, region=region):
|
|
421
421
|
data.append(r)
|
|
422
422
|
filename = f"suggestions_{_sanitize_keywords(keywords)}_{datetime.now():%Y%m%d_%H%M%S}"
|
|
423
423
|
if output == "print":
|
|
@@ -429,4 +429,4 @@ def suggestions(keywords, region, output, proxy):
|
|
|
429
429
|
|
|
430
430
|
|
|
431
431
|
if __name__ == "__main__":
|
|
432
|
-
cli(prog_name="
|
|
432
|
+
cli(prog_name="WEBS")
|
webscout/exceptions.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class
|
|
1
|
+
class WebscoutE(Exception):
|
|
2
2
|
"""Base exception class for webscout."""
|
webscout/utils.py
CHANGED
|
@@ -4,7 +4,7 @@ from html import unescape
|
|
|
4
4
|
from typing import Optional
|
|
5
5
|
from urllib.parse import unquote
|
|
6
6
|
|
|
7
|
-
from .exceptions import
|
|
7
|
+
from .exceptions import WebscoutE
|
|
8
8
|
|
|
9
9
|
REGEX_500_IN_URL = re.compile(r"(?:\d{3}-\d{2}\.js)")
|
|
10
10
|
REGEX_STRIP_TAGS = re.compile("<.*?>")
|
|
@@ -19,7 +19,7 @@ def _extract_vqd(html_bytes: bytes, keywords: str) -> Optional[str]:
|
|
|
19
19
|
return match.group(1).decode()
|
|
20
20
|
except Exception:
|
|
21
21
|
pass
|
|
22
|
-
raise
|
|
22
|
+
raise WebscoutE(f"_extract_vqd() {keywords=} Could not extract vqd.")
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _text_extract_json(html_bytes: bytes, keywords: str) -> Optional[str]:
|
|
@@ -30,7 +30,7 @@ def _text_extract_json(html_bytes: bytes, keywords: str) -> Optional[str]:
|
|
|
30
30
|
data = html_bytes[start:end]
|
|
31
31
|
return json.loads(data)
|
|
32
32
|
except Exception as ex:
|
|
33
|
-
raise
|
|
33
|
+
raise WebscoutE(f"_text_extract_json() {keywords=} {type(ex).__name__}: {ex}") from ex
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def _is_500_in_url(url: str) -> bool:
|
webscout/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.5"
|
webscout/webscout_search.py
CHANGED
|
@@ -4,15 +4,18 @@ from typing import Dict, Generator, Optional
|
|
|
4
4
|
|
|
5
5
|
import nest_asyncio
|
|
6
6
|
|
|
7
|
-
from .webscout_search_async import
|
|
7
|
+
from .webscout_search_async import AsyncWEBS
|
|
8
8
|
|
|
9
|
-
logger = logging.getLogger("
|
|
9
|
+
logger = logging.getLogger("webscout.WEBS")
|
|
10
10
|
nest_asyncio.apply()
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class
|
|
13
|
+
class WEBS(AsyncWEBS):
|
|
14
14
|
def __init__(self, headers=None, proxies=None, timeout=10):
|
|
15
|
-
|
|
15
|
+
super().__init__(headers, proxies, timeout)
|
|
16
|
+
|
|
17
|
+
def __enter__(self) -> "WEBS":
|
|
18
|
+
return self
|
|
16
19
|
|
|
17
20
|
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
18
21
|
asyncio.run(super().__aexit__(exc_type, exc_val, exc_tb))
|
|
@@ -11,34 +11,34 @@ from typing import AsyncGenerator, Deque, Dict, Optional, Set, Tuple
|
|
|
11
11
|
from curl_cffi import requests
|
|
12
12
|
from lxml import html
|
|
13
13
|
|
|
14
|
-
from .exceptions import
|
|
14
|
+
from .exceptions import WebscoutE
|
|
15
15
|
from .models import MapsResult
|
|
16
16
|
from .utils import _extract_vqd, _is_500_in_url, _normalize, _normalize_url, _text_extract_json
|
|
17
17
|
|
|
18
|
-
logger = logging.getLogger("
|
|
18
|
+
logger = logging.getLogger("webscout.AsyncWEBS")
|
|
19
19
|
# Not working on Windows, NotImplementedError (https://curl-cffi.readthedocs.io/en/latest/faq/)
|
|
20
20
|
if sys.platform.lower().startswith("win"):
|
|
21
21
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
class
|
|
25
|
-
"""
|
|
24
|
+
class AsyncWEBS:
|
|
25
|
+
"""Webscout async class to get search results from duckduckgo.com."""
|
|
26
26
|
|
|
27
27
|
def __init__(self, headers=None, proxies=None, timeout=10) -> None:
|
|
28
|
-
"""Initialize the
|
|
28
|
+
"""Initialize the AsyncWEBS object.
|
|
29
29
|
|
|
30
30
|
Args:
|
|
31
31
|
headers (dict, optional): Dictionary of headers for the HTTP client. Defaults to None.
|
|
32
32
|
proxies (Union[dict, str], optional): Proxies for the HTTP client (can be dict or str). Defaults to None.
|
|
33
33
|
timeout (int, optional): Timeout value for the HTTP client. Defaults to 10.
|
|
34
34
|
"""
|
|
35
|
-
self.proxies = proxies if proxies and isinstance(proxies, dict) else {"
|
|
35
|
+
self.proxies = proxies if proxies and isinstance(proxies, dict) else {"all": proxies}
|
|
36
36
|
self._asession = requests.AsyncSession(
|
|
37
37
|
headers=headers, proxies=self.proxies, timeout=timeout, impersonate="chrome"
|
|
38
38
|
)
|
|
39
39
|
self._asession.headers["Referer"] = "https://duckduckgo.com/"
|
|
40
40
|
|
|
41
|
-
async def __aenter__(self) -> "
|
|
41
|
+
async def __aenter__(self) -> "AsyncWEBS":
|
|
42
42
|
"""A context manager method that is called when entering the 'with' statement."""
|
|
43
43
|
return self
|
|
44
44
|
|
|
@@ -53,11 +53,11 @@ class AsyncDDGS:
|
|
|
53
53
|
resp_content = await resp.acontent()
|
|
54
54
|
logger.debug(f"_aget_url() {url} {resp.status_code} {resp.http_version} {resp.elapsed} {len(resp_content)}")
|
|
55
55
|
if _is_500_in_url(str(resp.url)) or resp.status_code == 202:
|
|
56
|
-
raise
|
|
56
|
+
raise WebscoutE("Ratelimit")
|
|
57
57
|
if resp.status_code == 200:
|
|
58
58
|
return resp_content
|
|
59
59
|
except Exception as ex:
|
|
60
|
-
raise
|
|
60
|
+
raise WebscoutE(f"_aget_url() {url} {type(ex).__name__}: {ex}") from ex
|
|
61
61
|
|
|
62
62
|
async def _aget_vqd(self, keywords: str) -> Optional[str]:
|
|
63
63
|
"""Get vqd value for a search query."""
|
|
@@ -74,7 +74,7 @@ class AsyncDDGS:
|
|
|
74
74
|
backend: str = "api",
|
|
75
75
|
max_results: Optional[int] = None,
|
|
76
76
|
) -> AsyncGenerator[Dict[str, Optional[str]], None]:
|
|
77
|
-
"""
|
|
77
|
+
"""webscout text search generator. Query params: https://duckduckgo.com/params.
|
|
78
78
|
|
|
79
79
|
Args:
|
|
80
80
|
keywords: keywords for query.
|
|
@@ -729,6 +729,7 @@ class AsyncDDGS:
|
|
|
729
729
|
"polygon_geojson": "0",
|
|
730
730
|
"format": "jsonv2",
|
|
731
731
|
}
|
|
732
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
732
733
|
try:
|
|
733
734
|
resp_content = await self._aget_url(
|
|
734
735
|
"GET",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary: Search for words, documents, images, news, maps, and text translation using the DuckDuckGo.com
|
|
5
|
-
|
|
6
|
-
Author:
|
|
7
|
-
Author-email: koulabhay25@gmail.com
|
|
3
|
+
Version: 1.0.5
|
|
4
|
+
Summary: Search for words, documents, images, news, maps, and text translation using the DuckDuckGo.com and yep.com periodically.
|
|
5
|
+
Author: OEvortex, Zaid
|
|
6
|
+
Author-email: helpingai5@gmail.com
|
|
8
7
|
Classifier: Development Status :: 5 - Production/Stable
|
|
9
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
9
|
Classifier: Operating System :: OS Independent
|
|
@@ -29,27 +28,33 @@ Provides-Extra: dev
|
|
|
29
28
|
Requires-Dist: ruff >=0.1.6 ; extra == 'dev'
|
|
30
29
|
Requires-Dist: pytest >=7.4.2 ; extra == 'dev'
|
|
31
30
|
|
|
32
|
-
Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com
|
|
33
|
-
|
|
34
|
-
**⚠️ Warning: use AsyncDDGS in asynchronous code**
|
|
31
|
+
Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com and yep.com
|
|
32
|
+
**⚠️ Warning: use AsyncWEBS in asynchronous code**
|
|
35
33
|
|
|
36
34
|
## Table of Contents
|
|
37
35
|
- [Table of Contents](#table-of-contents)
|
|
36
|
+
- [What is new](#what-is-new)
|
|
37
|
+
- [What is next](#what-is-next)
|
|
38
38
|
- [Install](#install)
|
|
39
39
|
- [CLI version](#cli-version)
|
|
40
|
-
- [Duckduckgo search operators](#duckduckgo-search-operators)
|
|
41
40
|
- [Regions](#regions)
|
|
42
|
-
- [
|
|
41
|
+
- [WEBS and AsyncWEBS classes](#webs-and-asyncwebs-classes)
|
|
43
42
|
- [Exceptions](#exceptions)
|
|
44
|
-
- [1. text() - text search by
|
|
45
|
-
- [2. answers() - instant answers by
|
|
46
|
-
- [3. images() - image search by
|
|
47
|
-
- [4. videos() - video search by
|
|
48
|
-
- [5. news() - news search by
|
|
49
|
-
- [6. maps() - map search by
|
|
50
|
-
- [7. translate() - translation by
|
|
51
|
-
- [8. suggestions() - suggestions by
|
|
52
|
-
|
|
43
|
+
- [1. `text()` - text search by DuckDuckGo.com and Yep.com](#1-text---text-search-by-duckduckgocom-and-yepcom)
|
|
44
|
+
- [2. `answers()` - instant answers by DuckDuckGo.com and Yep.com](#2-answers---instant-answers-by-duckduckgocom-and-yepcom)
|
|
45
|
+
- [3. `images()` - image search by DuckDuckGo.com and Yep.com](#3-images---image-search-by-duckduckgocom-and-yepcom)
|
|
46
|
+
- [4. `videos()` - video search by DuckDuckGo.com](#4-videos---video-search-by-duckduckgocom)
|
|
47
|
+
- [5. `news()` - news search by DuckDuckGo.com and yep.com](#5-news---news-search-by-duckduckgocom-and-yepcom)
|
|
48
|
+
- [6. `maps()` - map search by DuckDuckGo.com and](#6-maps---map-search-by-duckduckgocom-and)
|
|
49
|
+
- [7. `translate()` - translation by DuckDuckGo.com and Yep.com](#7-translate---translation-by-duckduckgocom-and-yepcom)
|
|
50
|
+
- [8. `suggestions()` - suggestions by DuckDuckGo.com and Yep.com](#8-suggestions---suggestions-by-duckduckgocom-and-yepcom)
|
|
51
|
+
|
|
52
|
+
## What is new
|
|
53
|
+
- Added yep.com as search engine.
|
|
54
|
+
- solved a error where translate was not working.
|
|
55
|
+
|
|
56
|
+
## What is next
|
|
57
|
+
- trying to add yepchat
|
|
53
58
|
## Install
|
|
54
59
|
```python
|
|
55
60
|
pip install -U webscout
|
|
@@ -61,23 +66,6 @@ pip install -U webscout
|
|
|
61
66
|
python -m webscout --help
|
|
62
67
|
```
|
|
63
68
|
|
|
64
|
-
CLI examples:
|
|
65
|
-
[Go To TOP](#TOP)
|
|
66
|
-
|
|
67
|
-
## Duckduckgo search operators
|
|
68
|
-
|
|
69
|
-
| Keywords example | Result|
|
|
70
|
-
| --- | --- |
|
|
71
|
-
| cats dogs | Results about cats or dogs |
|
|
72
|
-
| "cats and dogs" | Results for exact term "cats and dogs". If no results are found, related results are shown. |
|
|
73
|
-
| cats -dogs | Fewer dogs in results |
|
|
74
|
-
| cats +dogs | More dogs in results |
|
|
75
|
-
| cats filetype:pdf | PDFs about cats. Supported file types: pdf, doc(x), xls(x), ppt(x), html |
|
|
76
|
-
| dogs site:example.com | Pages about dogs from example.com |
|
|
77
|
-
| cats -site:example.com | Pages about cats, excluding example.com |
|
|
78
|
-
| intitle:dogs | Page title includes the word "dogs" |
|
|
79
|
-
| inurl:cats | Page url includes the word "cats" |
|
|
80
|
-
|
|
81
69
|
[Go To TOP](#TOP)
|
|
82
70
|
|
|
83
71
|
## Regions
|
|
@@ -158,31 +146,26 @@ ___
|
|
|
158
146
|
[Go To TOP](#TOP)
|
|
159
147
|
|
|
160
148
|
|
|
161
|
-
##
|
|
149
|
+
## WEBS and AsyncWEBS classes
|
|
162
150
|
|
|
163
|
-
The
|
|
164
|
-
To use the
|
|
165
|
-
To initialize an instance of the
|
|
166
|
-
```python3
|
|
167
|
-
class DDGS:
|
|
168
|
-
"""webscout class to get search results from duckduckgo.com
|
|
169
|
-
|
|
170
|
-
Args:
|
|
171
|
-
headers (dict, optional): Dictionary of headers for the HTTP client. Defaults to None.
|
|
172
|
-
proxies (Union[dict, str], optional): Proxies for the HTTP client (can be dict or str). Defaults to None.
|
|
173
|
-
timeout (int, optional): Timeout value for the HTTP client. Defaults to 10.
|
|
174
|
-
"""
|
|
175
|
-
```
|
|
151
|
+
The WEBS and AsyncWEBS classes are used to retrieve search results from DuckDuckGo.com and yep.com periodically.
|
|
152
|
+
To use the AsyncWEBS class, you can perform asynchronous operations using Python's asyncio library.
|
|
153
|
+
To initialize an instance of the WEBS or AsyncWEBS classes, you can provide the following optional arguments:
|
|
176
154
|
|
|
177
|
-
Here is an example of initializing the
|
|
155
|
+
Here is an example of initializing the WEBS class:
|
|
178
156
|
```python3
|
|
179
|
-
from webscout import
|
|
157
|
+
from webscout import WEBS
|
|
180
158
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
# Instantiating the WEBS class from webscout module
|
|
160
|
+
WEBS_instance = WEBS()
|
|
161
|
+
|
|
162
|
+
# Fetching text results for the query "python programming" with a maximum of 5 results
|
|
163
|
+
results = [result for result in WEBS_instance.text("python programming", max_results=5)]
|
|
164
|
+
|
|
165
|
+
# Displaying the obtained results
|
|
166
|
+
print(results)
|
|
184
167
|
```
|
|
185
|
-
Here is an example of initializing the
|
|
168
|
+
Here is an example of initializing the AsyncWEBS class:
|
|
186
169
|
```python3
|
|
187
170
|
import asyncio
|
|
188
171
|
import logging
|
|
@@ -191,7 +174,7 @@ from itertools import chain
|
|
|
191
174
|
from random import shuffle
|
|
192
175
|
|
|
193
176
|
import requests
|
|
194
|
-
from webscout import
|
|
177
|
+
from webscout import AsyncWEBS
|
|
195
178
|
|
|
196
179
|
# bypass curl-cffi NotImplementedError in windows https://curl-cffi.readthedocs.io/en/latest/faq/
|
|
197
180
|
if sys.platform.lower().startswith("win"):
|
|
@@ -204,8 +187,8 @@ def get_words():
|
|
|
204
187
|
return words
|
|
205
188
|
|
|
206
189
|
async def aget_results(word):
|
|
207
|
-
async with
|
|
208
|
-
results = [r async for r in
|
|
190
|
+
async with AsyncWEBS(proxies=proxies) as WEBS:
|
|
191
|
+
results = [r async for r in WEBS.text(word, max_results=None)]
|
|
209
192
|
return results
|
|
210
193
|
|
|
211
194
|
async def main():
|
|
@@ -224,48 +207,51 @@ if __name__ == "__main__":
|
|
|
224
207
|
logging.basicConfig(level=logging.DEBUG)
|
|
225
208
|
asyncio.run(main())
|
|
226
209
|
```
|
|
227
|
-
It is important to note that the
|
|
210
|
+
It is important to note that the WEBS and AsyncWEBS classes should always be used as a context manager (with statement).
|
|
228
211
|
This ensures proper resource management and cleanup, as the context manager will automatically handle opening and closing the HTTP client connection.
|
|
229
212
|
|
|
230
213
|
## Exceptions
|
|
231
214
|
|
|
232
215
|
Exceptions:
|
|
233
|
-
- `
|
|
216
|
+
- `WebscoutE`: Raised when there is a generic exception during the API request.
|
|
234
217
|
|
|
235
218
|
|
|
236
|
-
|
|
219
|
+
Here are the rewritten Python scripts for accessing various functionalities using the WEBS class from the webscout module, in HelpingAI style, for DuckDuckGo.com and Yep.com without explicitly specifying the search engine:
|
|
220
|
+
|
|
221
|
+
### 1. `text()` - text search by DuckDuckGo.com and Yep.com
|
|
237
222
|
|
|
238
223
|
```python
|
|
239
|
-
from webscout import
|
|
224
|
+
from webscout import WEBS
|
|
240
225
|
|
|
241
|
-
|
|
242
|
-
|
|
226
|
+
# Text search for 'live free or die' using DuckDuckGo.com and Yep.com
|
|
227
|
+
with WEBS() as WEBS:
|
|
228
|
+
for r in WEBS.text('live free or die', region='wt-wt', safesearch='off', timelimit='y', max_results=10):
|
|
243
229
|
print(r)
|
|
244
230
|
|
|
245
|
-
|
|
246
|
-
with DDGS() as ddgs:
|
|
247
|
-
for r in ddgs.text('russia filetype:pdf', region='wt-wt', safesearch='off', timelimit='y', max_results=10):
|
|
231
|
+
for r in WEBS.text('live free or die', region='wt-wt', safesearch='off', timelimit='y', max_results=10):
|
|
248
232
|
print(r)
|
|
249
233
|
```
|
|
250
234
|
|
|
251
|
-
|
|
235
|
+
### 2. `answers()` - instant answers by DuckDuckGo.com and Yep.com
|
|
252
236
|
|
|
253
237
|
```python
|
|
254
|
-
from webscout import
|
|
238
|
+
from webscout import WEBS
|
|
255
239
|
|
|
256
|
-
|
|
257
|
-
|
|
240
|
+
# Instant answers for the query "sun" using DuckDuckGo.com and Yep.com
|
|
241
|
+
with WEBS() as WEBS:
|
|
242
|
+
for r in WEBS.answers("sun"):
|
|
258
243
|
print(r)
|
|
259
244
|
```
|
|
260
245
|
|
|
261
|
-
|
|
246
|
+
### 3. `images()` - image search by DuckDuckGo.com and Yep.com
|
|
262
247
|
|
|
263
248
|
```python
|
|
264
|
-
from webscout import
|
|
249
|
+
from webscout import WEBS
|
|
265
250
|
|
|
266
|
-
|
|
251
|
+
# Image search for the keyword 'butterfly' using DuckDuckGo.com and Yep.com
|
|
252
|
+
with WEBS() as WEBS:
|
|
267
253
|
keywords = 'butterfly'
|
|
268
|
-
|
|
254
|
+
WEBS_images_gen = WEBS.images(
|
|
269
255
|
keywords,
|
|
270
256
|
region="wt-wt",
|
|
271
257
|
safesearch="off",
|
|
@@ -276,18 +262,19 @@ with DDGS() as ddgs:
|
|
|
276
262
|
license_image=None,
|
|
277
263
|
max_results=100,
|
|
278
264
|
)
|
|
279
|
-
for r in
|
|
265
|
+
for r in WEBS_images_gen:
|
|
280
266
|
print(r)
|
|
281
267
|
```
|
|
282
268
|
|
|
283
|
-
|
|
269
|
+
### 4. `videos()` - video search by DuckDuckGo.com
|
|
284
270
|
|
|
285
271
|
```python
|
|
286
|
-
from webscout import
|
|
272
|
+
from webscout import WEBS
|
|
287
273
|
|
|
288
|
-
|
|
274
|
+
# Video search for the keyword 'tesla' using DuckDuckGo.com
|
|
275
|
+
with WEBS() as WEBS:
|
|
289
276
|
keywords = 'tesla'
|
|
290
|
-
|
|
277
|
+
WEBS_videos_gen = WEBS.videos(
|
|
291
278
|
keywords,
|
|
292
279
|
region="wt-wt",
|
|
293
280
|
safesearch="off",
|
|
@@ -296,56 +283,59 @@ with DDGS() as ddgs:
|
|
|
296
283
|
duration="medium",
|
|
297
284
|
max_results=100,
|
|
298
285
|
)
|
|
299
|
-
for r in
|
|
286
|
+
for r in WEBS_videos_gen:
|
|
300
287
|
print(r)
|
|
301
288
|
```
|
|
302
289
|
|
|
303
|
-
|
|
290
|
+
### 5. `news()` - news search by DuckDuckGo.com and yep.com
|
|
304
291
|
|
|
305
292
|
```python
|
|
306
|
-
from webscout import
|
|
293
|
+
from webscout import WEBS
|
|
307
294
|
|
|
308
|
-
|
|
295
|
+
# News search for the keyword 'holiday' using DuckDuckGo.com and yep.com
|
|
296
|
+
with WEBS() as WEBS:
|
|
309
297
|
keywords = 'holiday'
|
|
310
|
-
|
|
298
|
+
WEBS_news_gen = WEBS.news(
|
|
311
299
|
keywords,
|
|
312
300
|
region="wt-wt",
|
|
313
301
|
safesearch="off",
|
|
314
302
|
timelimit="m",
|
|
315
303
|
max_results=20
|
|
316
304
|
)
|
|
317
|
-
for r in
|
|
305
|
+
for r in WEBS_news_gen:
|
|
318
306
|
print(r)
|
|
319
307
|
```
|
|
320
308
|
|
|
321
|
-
|
|
322
|
-
## 6. maps() - map search by duckduckgo.com
|
|
309
|
+
### 6. `maps()` - map search by DuckDuckGo.com and
|
|
323
310
|
|
|
324
311
|
```python
|
|
325
|
-
from webscout import
|
|
312
|
+
from webscout import WEBS
|
|
326
313
|
|
|
327
|
-
|
|
328
|
-
|
|
314
|
+
# Map search for the keyword 'school' in 'anantnag' using DuckDuckGo.com
|
|
315
|
+
with WEBS() as WEBS:
|
|
316
|
+
for r in WEBS.maps("school", place="anantnag", max_results=50):
|
|
329
317
|
print(r)
|
|
330
318
|
```
|
|
331
319
|
|
|
332
|
-
|
|
333
|
-
## 7. translate() - translation by duckduckgo.com
|
|
320
|
+
### 7. `translate()` - translation by DuckDuckGo.com and Yep.com
|
|
334
321
|
|
|
335
322
|
```python
|
|
336
|
-
from webscout import
|
|
323
|
+
from webscout import WEBS
|
|
337
324
|
|
|
338
|
-
|
|
325
|
+
# Translation of the keyword 'school' to German ('hi') using DuckDuckGo.com and Yep.com
|
|
326
|
+
with WEBS() as WEBS:
|
|
339
327
|
keywords = 'school'
|
|
340
|
-
r =
|
|
328
|
+
r = WEBS.translate(keywords, to="hi")
|
|
341
329
|
print(r)
|
|
342
330
|
```
|
|
343
331
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
332
|
+
### 8. `suggestions()` - suggestions by DuckDuckGo.com and Yep.com
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
from webscout import WEBS
|
|
347
336
|
|
|
348
|
-
|
|
349
|
-
|
|
337
|
+
# Suggestions for the keyword 'fly' using DuckDuckGo.com and Yep.com
|
|
338
|
+
with WEBS() as WEBS:
|
|
339
|
+
for r in WEBS.suggestions("fly"):
|
|
350
340
|
print(r)
|
|
351
341
|
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
webscout/__init__.py,sha256=vHJGZexYIaWDTHfMimqA7enct9b7zPDf6jLsS7NDBiA,536
|
|
2
|
+
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
3
|
+
webscout/cli.py,sha256=9opO5KynQ3LA5gPW2czlmy7-ZdfUae6ccrny3vibqzQ,17757
|
|
4
|
+
webscout/exceptions.py,sha256=7u52Mt5iyEUCZvaZuEYwQVV8HL8IdZBv1r5s5Ss_xU0,75
|
|
5
|
+
webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
6
|
+
webscout/utils.py,sha256=M2ocDpYOVd9lTZA3VGdK_p80Xsr-VPeAoUUCFaMWCqk,1610
|
|
7
|
+
webscout/version.py,sha256=lfZikIZ2prlMV6RkxhMRZj5dAeD0TCswIWS46kSjXw0,23
|
|
8
|
+
webscout/webscout_search.py,sha256=_kuNpRhbgge6MubxlsRe9kzBKlHoPEH6-93ILMpycfg,2351
|
|
9
|
+
webscout/webscout_search_async.py,sha256=lNdR18-y8O9HqFsHvlzBYg18qeI12uLEXIzFMP3D_XU,35070
|
|
10
|
+
webscout-1.0.5.dist-info/LICENSE.md,sha256=ple694nFBJxLq83VmOoXLaKHCuN6Zmx4BbcMMLjAWmc,1087
|
|
11
|
+
webscout-1.0.5.dist-info/METADATA,sha256=4xfSlYmNlV5kG6OfoN4zksDFOPM52JzlSvA6027yVow,10383
|
|
12
|
+
webscout-1.0.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
13
|
+
webscout-1.0.5.dist-info/entry_points.txt,sha256=aRJf8ZQpdyIVFPxOHndOORY3pqJ3JfmUp8fQX95Ntf4,42
|
|
14
|
+
webscout-1.0.5.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
|
|
15
|
+
webscout-1.0.5.dist-info/RECORD,,
|
webscout-1.0.2.dist-info/RECORD
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
webscout/__init__.py,sha256=zHNzosf3eGFKZElLcJY4g97QLNHF6a8frP5leUd4BPY,547
|
|
2
|
-
webscout/__main__.py,sha256=JdZY7xWYnoQGBZkv2N4VpMDdcPHA16i-Hod7Z1ULev8,135
|
|
3
|
-
webscout/cli.py,sha256=9R8OHJdSVS_koqGLJm70GFwWYQzqgTxuI_zt77JG_p8,17757
|
|
4
|
-
webscout/exceptions.py,sha256=GSidNXKbT3wjrny3hSb9s9t3OeLxU0Rv3IHyn-JSi6M,91
|
|
5
|
-
webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
6
|
-
webscout/utils.py,sha256=sIZ466_XgoLcd6IC-GgwzU1cSo2WwfEhKe1FKMMYImw,1658
|
|
7
|
-
webscout/version.py,sha256=aE8PlHPx02hUJId9SiLOSxGJarExAMs8b28EJBMp20g,64
|
|
8
|
-
webscout/webscout_search.py,sha256=8R4sDvX3_IZr5MgAW6k5NSSvJAj5Nep4zt5IMzxqiBs,2299
|
|
9
|
-
webscout/webscout_search_async.py,sha256=jLcizw-Nqx4hrwbVxhhDX6hUtzJgSlE4V7S0eLZcUf4,35078
|
|
10
|
-
webscout-1.0.2.dist-info/LICENSE.md,sha256=ple694nFBJxLq83VmOoXLaKHCuN6Zmx4BbcMMLjAWmc,1087
|
|
11
|
-
webscout-1.0.2.dist-info/METADATA,sha256=j15TF1sY2LphTtTZgSKYw2yeKZYXAs2w0H0IcNmnJ0w,10200
|
|
12
|
-
webscout-1.0.2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
13
|
-
webscout-1.0.2.dist-info/entry_points.txt,sha256=0RXrvIkLYLKfJnTn3_5Iv139Wc8qh_AUVhfIzqmZns8,42
|
|
14
|
-
webscout-1.0.2.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
|
|
15
|
-
webscout-1.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|