deedy5 / duckduckgo_search

Search for words, documents, images, videos, news, maps and text translation using the DuckDuckGo.com search engine. Downloading files and images to a local hard drive.
MIT License
927 stars 117 forks source link

Solve Ratelimit #211

Closed QIN2DIM closed 3 months ago

QIN2DIM commented 3 months ago

Add (Faker) Headers

async def main(keywords: str):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0"
    }

    results = DDGS(headers=headers).text(keywords, max_results=5)
    print(results)

    return text
deedy5 commented 3 months ago

As a rule, you do not need to specify headers. Requests already contain headers that mimic the browser.