Giter Club home page Giter Club logo

duckduckgo-api's Introduction

duckduckgo-api

Use vercel

https://duckduckgo-api.vercel.app/search?q=啊对对对是什么梗&max_results=3

使用vercel部署的本项目,免费,但是vercel免费用量用完就无了

可点下方按钮部署到自己的Vercel

Deploy to Vercel

设置 Vercel 的指导
  1. 前往 vercel.com
  2. 点击 Log in
  3. 点击 Continue with GitHub 通过 GitHub 进行登录
  4. 登录 GitHub 并允许访问所有存储库(如果系统这样提示)
  5. Fork 这个仓库
  6. 返回到你的 Vercel dashboard
  7. 选择 Import Project
  8. 选择 Import Git Repository
  9. 选择 root 并将所有内容保持不变,并且只需添加名为 PAT_1 的环境变量(如图所示),其中将包含一个个人访问令牌(PAT),你可以在这里轻松创建(保留默认,并且只需要命名下,名字随便)
  10. 点击 deploy,这就完成了,查看你的域名就可使用 API 了!

Self host

###use docker

docker run -p 8000:8000 binjie09/duckduckgo-api

then get http://localhost:8000/search?q=啊对对对是什么梗&max_results=3

[
    {
        "body": "TikTok video from 乐萱 (@rachel_5205). 原聲 - 小熊🐻 - 啊对对对.",
        "href": "https://www.tiktok.com/@rachel_5205/video/7117859473565289755",
        "title": "乐萱 (@rachel_5205) 's videos with 原聲 - 小熊🐻 - 啊对对对 | TikTok"
    },
    {
        "body": "很显然,这名主播的目的,是想要凭借\"啊对对对\"这种说法讽刺对方的死鸭子嘴硬,表现出的是一种\"你都已经这样了,那我为什么不顺从你呢?\"但看\"啊对对对\"似乎还能看到表达赞同和认可的那份本意,可将其放到如…",
        "href": "https://www.sohu.com/a/534828306_119620",
        "title": "讽刺摆烂的\"啊对对对\",为何成了\"摆烂圣经\"?_含义_对方_态度"
    },
    {
        "body": "\"啊对对对\"完全不同,在如今这个常用的语境下,当你和对方讲道理或者指责对方希望他能够改正的时候,这句\"啊对对对\"透露的只有藐视和满不在乎。. 也正是这满满的负能量,使得\"啊对对对\"发臭和让人反感的速度要远远快于\"绝绝子\"。. 如果将 ...",
        "href": "https://www.ali213.net/news/html/2022-4/665405_3.html",
        "title": "讽刺摆烂的\"啊对对对\",为何成了\"摆烂圣经\"?(3)_游侠网 Ali213.net"
    }
]

self host

git clone https://github.com/binjie09/duckduckgo-api.git
cd duckduckgo-api
python3 -m venv myenv && source myenv/bin/activate && pip install -r requirements.txt
gunicorn -b 0.0.0.0:8000 app:app

duckduckgo-api's People

Contributors

binjie09 avatar qi-mooo avatar suiyunsy avatar zmh-program avatar zyx-a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

duckduckgo-api's Issues

Vercel 近期重新部署报错

Running build in Washington, D.C., USA (East) – iad1
14:56:38.669 | Cloning github.com/binjie09/duckduckgo-api (Branch: main, Commit: cc67c06)
14:56:38.941 | Cloning completed: 272.705ms
14:56:39.080 | Previous build cache not available
14:56:39.370 | Running "vercel build"
14:56:39.966 | Vercel CLI 34.2.0
14:56:40.149 | WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
14:56:40.178 | Installing required dependencies...
14:56:51.415 | Failed to run "pip3.9 install --disable-pip-version-check --target . --upgrade -r /vercel/path0/requirements.txt"
14:56:51.415 | Error: Command failed: pip3.9 install --disable-pip-version-check --target . --upgrade -r /vercel/path0/requirements.txt
14:56:51.416 | error: subprocess-exited-with-error
14:56:51.416 |  
14:56:51.416 | × Preparing metadata (pyproject.toml) did not run successfully.
14:56:51.416 | │ exit code: 1
14:56:51.416 | ╰─> [6 lines of output]
14:56:51.416 |  
14:56:51.416 | Cargo, the Rust package manager, is not installed or is not on PATH.
14:56:51.416 | This package requires Rust and Cargo to compile extensions. Install it through
14:56:51.416 | the system's package manager or via https://rustup.rs/
14:56:51.416 |  
14:56:51.416 | Checking for Rust toolchain....
14:56:51.416 | [end of output]
14:56:51.416 |  
14:56:51.416 | note: This error originates from a subprocess, and is likely not a problem with pip.
14:56:51.416 | error: metadata-generation-failed
14:56:51.416 |  
14:56:51.416 | × Encountered error while generating package metadata.
14:56:51.416 | ╰─> See above for output.
14:56:51.417 |  
14:56:51.417 | note: This is an issue with the package mentioned above, not pip.
14:56:51.417 | hint: See above for details.
14:56:51.417 |  
14:56:51.417 | Collecting certifi==2022.12.7 (from -r /vercel/path0/requirements.txt (line 1))
14:56:51.417 | Downloading certifi-2022.12.7-py3-none-any.whl.metadata (2.9 kB)
14:56:51.417 | Collecting charset-normalizer==3.1.0 (from -r /vercel/path0/requirements.txt (line 2))
14:56:51.417 | Downloading charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (30 kB)
14:56:51.417 | Collecting click>=8.1.3 (from -r /vercel/path0/requirements.txt (line 3))
14:56:51.417 | Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
14:56:51.417 | Collecting duckduckgo-search>=3.9.9 (from -r /vercel/path0/requirements.txt (line 4))
14:56:51.417 | Downloading duckduckgo_search-6.1.0-py3-none-any.whl.metadata (18 kB)
14:56:51.417 | Collecting Flask==2.2.3 (from -r /vercel/path0/requirements.txt (line 5))
14:56:51.417 | Downloading Flask-2.2.3-py3-none-any.whl.metadata (3.9 kB)
14:56:51.417 | Collecting gunicorn==20.1.0 (from -r /vercel/path0/requirements.txt (line 6))
14:56:51.417 | Downloading gunicorn-20.1.0-py3-none-any.whl.metadata (3.8 kB)
14:56:51.417 | Collecting idna==3.4 (from -r /vercel/path0/requirements.txt (line 7))
14:56:51.417 | Downloading idna-3.4-py3-none-any.whl.metadata (9.8 kB)
14:56:51.417 | Collecting importlib-metadata==6.1.0 (from -r /vercel/path0/requirements.txt (line 8))
14:56:51.417 | Downloading importlib_metadata-6.1.0-py3-none-any.whl.metadata (5.0 kB)
14:56:51.417 | Collecting itsdangerous==2.1.2 (from -r /vercel/path0/requirements.txt (line 9))
14:56:51.417 | Downloading itsdangerous-2.1.2-py3-none-any.whl.metadata (2.9 kB)
14:56:51.417 | Collecting Jinja2==3.1.2 (from -r /vercel/path0/requirements.txt (line 10))
14:56:51.417 | Downloading Jinja2-3.1.2-py3-none-any.whl.metadata (3.5 kB)
14:56:51.417 | Collecting MarkupSafe==2.1.2 (from -r /vercel/path0/requirements.txt (line 11))
14:56:51.417 | Downloading MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
14:56:51.417 | Collecting requests>=2.28.2 (from -r /vercel/path0/requirements.txt (line 12))
14:56:51.417 | Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
14:56:51.417 | Collecting urllib3==1.26.15 (from -r /vercel/path0/requirements.txt (line 13))
14:56:51.417 | Downloading urllib3-1.26.15-py2.py3-none-any.whl.metadata (48 kB)
14:56:51.417 | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.1/48.1 kB 17.0 MB/s eta 0:00:00
14:56:51.418 | Collecting Werkzeug==2.2.3 (from -r /vercel/path0/requirements.txt (line 14))
14:56:51.418 | Downloading Werkzeug-2.2.3-py3-none-any.whl.metadata (4.4 kB)
14:56:51.418 | Collecting zipp==3.15.0 (from -r /vercel/path0/requirements.txt (line 15))
14:56:51.418 | Downloading zipp-3.15.0-py3-none-any.whl.metadata (3.7 kB)
14:56:51.418 | Collecting setuptools>=3.0 (from gunicorn==20.1.0->-r /vercel/path0/requirements.txt (line 6))
14:56:51.418 | Downloading setuptools-69.5.1-py3-none-any.whl.metadata (6.2 kB)
14:56:51.418 | Collecting pyreqwest-impersonate>=0.4.5 (from duckduckgo-search>=3.9.9->-r /vercel/path0/requirements.txt (line 4))
14:56:51.418 | Downloading pyreqwest_impersonate-0.4.5.tar.gz (129 kB)
14:56:51.418 | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 129.8/129.8 kB 38.1 MB/s eta 0:00:00
14:56:51.418 | Installing build dependencies: started
14:56:51.418 | Installing build dependencies: finished with status 'done'
14:56:51.418 | Getting requirements to build wheel: started
14:56:51.418 | Getting requirements to build wheel: finished with status 'done'
14:56:51.418 | Preparing metadata (pyproject.toml): started
14:56:51.418 | Preparing metadata (pyproject.toml): finished with status 'error'
14:56:51.418 |  
14:56:51.807

服务器部署请求报500

<!doctype html>

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

本地docker部署无法联网,202 Ratelimit

访问端口网页提示The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

查看后台日志:
2024-05-08T23:46:20.429958317Z /usr/local/lib/python3.9/asyncio/events.py:80: UserWarning: lxml is not installed. Using backend='api'.
2024-05-08T23:46:20.429996425Z self._context.run(self._callback, *self._args)
2024-05-08T23:46:21.483796001Z [2024-05-09 07:46:21,469] ERROR in app: Exception on /search [GET]
2024-05-08T23:46:21.483831605Z Traceback (most recent call last):
2024-05-08T23:46:21.483856771Z File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2528, in wsgi_app
2024-05-08T23:46:21.483862445Z response = self.full_dispatch_request()
2024-05-08T23:46:21.483866737Z File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request
2024-05-08T23:46:21.483871288Z rv = self.handle_user_exception(e)
2024-05-08T23:46:21.483875185Z File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
2024-05-08T23:46:21.483879346Z rv = self.dispatch_request()
2024-05-08T23:46:21.483883409Z File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
2024-05-08T23:46:21.483887567Z return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2024-05-08T23:46:21.483891649Z File "/usr/local/lib/python3.9/site-packages/asgiref/sync.py", line 254, in call
2024-05-08T23:46:21.483895803Z return call_result.result()
2024-05-08T23:46:21.483899705Z File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 439, in result
2024-05-08T23:46:21.483903910Z return self.__get_result()
2024-05-08T23:46:21.483908091Z File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
2024-05-08T23:46:21.483912153Z raise self._exception
2024-05-08T23:46:21.483916191Z File "/usr/local/lib/python3.9/site-packages/asgiref/sync.py", line 331, in main_wrap
2024-05-08T23:46:21.483920180Z result = await self.awaitable(*args, **kwargs)
2024-05-08T23:46:21.483924263Z File "/app/app.py", line 26, in search
2024-05-08T23:46:21.483928195Z ddgs_gen = ddgs.text(keywords, safesearch='Off', timelimit='y', backend="lite")
2024-05-08T23:46:21.483932447Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search.py", line 57, in text
2024-05-08T23:46:21.483936543Z return self._run_async_in_thread(super().text(*args, **kwargs))
2024-05-08T23:46:21.483940867Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search.py", line 53, in _run_async_in_thread
2024-05-08T23:46:21.483945337Z result = future.result()
2024-05-08T23:46:21.483950253Z File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 446, in result
2024-05-08T23:46:21.483955149Z return self.__get_result()
2024-05-08T23:46:21.483959936Z File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
2024-05-08T23:46:21.483964933Z raise self._exception
2024-05-08T23:46:21.483969531Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 167, in text
2024-05-08T23:46:21.483974499Z results = await self._text_api(keywords, region, safesearch, timelimit, max_results)
2024-05-08T23:46:21.483979735Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 258, in _text_api
2024-05-08T23:46:21.483991298Z raise e
2024-05-08T23:46:21.483996071Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 253, in _text_api
2024-05-08T23:46:21.484000578Z await asyncio.gather(*tasks)
2024-05-08T23:46:21.484004828Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 229, in _text_api_page
2024-05-08T23:46:21.484009181Z resp_content = await self._aget_url("GET", "https://links.duckduckgo.com/d.js", params=payload)
2024-05-08T23:46:21.484013688Z File "/usr/local/lib/python3.9/site-packages/duckduckgo_search/duckduckgo_search_async.py", line 124, in _aget_url
2024-05-08T23:46:21.484018149Z raise RatelimitException(f"{resp.url} {resp.status_code} Ratelimit")
2024-05-08T23:46:21.484022685Z duckduckgo_search.exceptions.RatelimitException: https://links.duckduckgo.com/d.js?q=hi&kl=wt-wt&l=wt-wt&p=&s=0&df=y&vqd=4-185712780087836999332350966763191802734&ex=-2 202 Ratelimit

Host docker部署:500 Internal Server Error: TypeError

按照docker部署的方法,部署后如图:
image

公网访问报错500:
image

TypeError: The view function for 'hello_world' did not return a valid response. The function either returned None or ended without a return statement.
image
请问要怎么解决,谢谢。

404: NOT_FOUND

部署后网页显示
404: NOT_FOUND
Code: NOT_FOUND
ID: sfo1::pvwz4-1709090754606-ecc43d39709e

请问是我步骤出错了吗

搜索能不能实现自定义指定网站

如题 因为搜索的信息太广泛,日常小问题可能没什么问题。 但是对于一些数据分析或者相关领域的问题,比如投资理财这种数据,靠搜索是不行的。即便是可以搜索到,信息量也不准确,没有参考价值。

Vercel和本地Docker部署均出现500错误

访问网页显示【500 Internal Server Error】
后台报错日志附上,Vercel和Docker报错是一样的。

[ERROR]	2024-05-11T11:44:16.097Z	ad9238df-0118-41ca-9f7b-642759c9e5cc	Exception on /search [GET]
Traceback (most recent call last):
  File "/var/task/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/var/task/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/var/task/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/task/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/var/task/asgiref/sync.py", line 254, in __call__
    return call_result.result()
  File "/var/lang/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/var/lang/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/var/task/asgiref/sync.py", line 331, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "./app.py", line 26, in search
    ddgs_gen = ddgs.text(keywords, safesearch='Off', timelimit='y', backend="lite")
  File "/var/task/duckduckgo_search/duckduckgo_search.py", line 57, in text
    return self._run_async_in_thread(super().text(*args, **kwargs))
  File "/var/task/duckduckgo_search/duckduckgo_search.py", line 53, in _run_async_in_thread
    result = future.result()
  File "/var/lang/lib/python3.9/concurrent/futures/_base.py", line 446, in result
    return self.__get_result()
  File "/var/lang/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/var/task/duckduckgo_search/duckduckgo_search_async.py", line 167, in text
    results = await self._text_api(keywords, region, safesearch, timelimit, max_results)
  File "/var/task/duckduckgo_search/duckduckgo_search_async.py", line 258, in _text_api
    raise e
  File "/var/task/duckduckgo_search/duckduckgo_search_async.py", line 253, in _text_api
    await asyncio.gather(*tasks)
  File "/var/task/duckduckgo_search/duckduckgo_search_async.py", line 229, in _text_api_page
    resp_content = await self._aget_url("GET", "https://links.duckduckgo.com/d.js", params=payload)
  File "/var/task/duckduckgo_search/duckduckgo_search_async.py", line 124, in _aget_url
    raise RatelimitException(f"{resp.url} {resp.status_code} Ratelimit")
duckduckgo_search.exceptions.RatelimitException: https://links.duckduckgo.com/d.js?q=%E7%BE%8E%E5%9B%BD&kl=wt-wt&l=wt-wt&p=&s=0&df=y&vqd=4-265164403837274910116468914437927397460&ex=-2 202 Ratelimit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.