Skip to content

Commit

Permalink
V4.1.1 (#163)
Browse files Browse the repository at this point in the history
1. _get_url(): bugfix exception message,
2. update README (proxies, bypass curl-cffi NotImplementedError in windows),
3. update bug_report.md
  • Loading branch information
deedy5 authored Dec 24, 2023
1 parent 256c0fd commit 25e7059
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
22 changes: 9 additions & 13 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---
**Before you open an issue:**
1. Make sure you have the latest version installed. Check: `ddgs version`. Update: `pip install -U duckduckgo_search`
3. Try reinstalling the library: `pip install -I duckduckgo_search`
4. Make sure the site https://duckduckgo.com is accessible in your browser
5. Try using a proxy. The site may block ip for a while.
- [ ] I have the latest version. (Check: `ddgs version`. Update: `pip install -U duckduckgo_search`)</br>
- [ ] I tried reinstalling the library. (`pip install -I duckduckgo_search`)
- [ ] https://duckduckgo.com is accessible in my browser
- [ ] I tried using a proxy (the site may block ip for a while)

## Describe the bug

**Describe the bug**
What the bug is.

**Debug log**

Add `logging.basicConfig(level=logging.DEBUG)` to the beginning of your script and attach log to the issue.

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Specify this information**

- OS
- environment
- duckduckgo_search version
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Search for words, documents, images, videos, news, maps and text translation usi
* [Duckduckgo search operators](#duckduckgo-search-operators)
* [Regions](#regions)
* [DDGS and AsyncDDGS classes](#ddgs-and-asyncddgs-classes)
* [Using proxy](#using-proxy)
* [Proxies](#proxies)
* [Exceptions](#exceptions)
* [1. text() - text search](#1-text---text-search-by-duckduckgocom)
* [2. answers() - instant answers](#2-answers---instant-answers-by-duckduckgocom)
Expand Down Expand Up @@ -183,8 +183,13 @@ with DDGS() as ddgs:
Here is an example of initializing the AsyncDDGS class:
```python3
import asyncio
import sys
from duckduckgo_search import AsyncDDGS

# bypass curl-cffi NotImplementedError in windows https://curl-cffi.readthedocs.io/en/latest/faq/
if sys.platform.lower().startswith("win"):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

async def get_results():
async with AsyncDDGS() as ddgs:
results = [r async for r in ddgs.text("cat", max_results=5)]
Expand All @@ -202,7 +207,13 @@ This ensures proper resource management and cleanup, as the context manager will

[Go To TOP](#TOP)

## Using proxy
## Proxies
Proxy can be specified as a dictionary or just a string
```python
proxies = {"http": "socks5://localhost:9150", "https": "socks5://localhost:9150"}
proxies = "socks5://localhost:9150"
```

*1. The easiest way. Launch the Tor Browser*
```python3
from duckduckgo_search import DDGS
Expand Down
2 changes: 1 addition & 1 deletion duckduckgo_search/duckduckgo_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _get_url(self, method: str, url: str, **kwargs) -> Optional[requests.Respons
logger.debug(f"_get_url() {url} {resp.status_code} {resp.http_version} {resp.elapsed} {len(resp.content)}")
resp.raise_for_status()
if _is_500_in_url(str(resp.url)) or resp.status_code == 202:
raise
raise DuckDuckGoSearchException("Ratelimit")
if resp.status_code == 200:
return resp
except Exception as ex:
Expand Down
2 changes: 1 addition & 1 deletion duckduckgo_search/duckduckgo_search_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def _get_url(self, method: str, url: str, **kwargs) -> Optional[requests.R
logger.debug(f"_get_url() {url} {resp.status_code} {resp.http_version} {resp.elapsed} {len(resp.content)}")
resp.raise_for_status()
if _is_500_in_url(str(resp.url)) or resp.status_code == 202:
raise
raise DuckDuckGoSearchException("Ratelimit")
if resp.status_code == 200:
return resp
except Exception as ex:
Expand Down
2 changes: 1 addition & 1 deletion duckduckgo_search/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.1.0"
__version__ = "4.1.1"

0 comments on commit 25e7059

Please sign in to comment.