Skip to content

Commit

Permalink
v6.0.0 Migrate to pyreqwest_impersonate, AsyncDDGS: all functions w…
Browse files Browse the repository at this point in the history
…ith `a` (#216)
  • Loading branch information
deedy5 authored May 14, 2024
1 parent a685314 commit bf90f27
Show file tree
Hide file tree
Showing 7 changed files with 1,176 additions and 873 deletions.
10 changes: 5 additions & 5 deletions duckduckgo_search/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from urllib.parse import unquote

import click
from curl_cffi import requests
import pyreqwest_impersonate as pri

from .duckduckgo_search import DDGS
from .utils import json_dumps
Expand Down Expand Up @@ -81,10 +81,10 @@ def _sanitize_keywords(keywords):

def _download_file(url, dir_path, filename, proxy):
try:
resp = requests.get(url, proxy=proxy, impersonate="chrome", timeout=10)
resp.raise_for_status()
with open(os.path.join(dir_path, filename[:200]), "wb") as file:
file.write(resp.content)
resp = pri.Client(proxy=proxy, impersonate="chrome_124", timeout=10, verify=False).get(url)
if resp.status_code == 200:
with open(os.path.join(dir_path, filename[:200]), "wb") as file:
file.write(resp.content)
except Exception as ex:
logger.debug(f"download_file url={url} {type(ex).__name__} {ex}")

Expand Down
Loading

0 comments on commit bf90f27

Please sign in to comment.