赞
踩
DuckDuckGo 创立于 2008 年,创始人是毕业于麻省理工的 Gabriel Weinberg。谈到这个奇怪的网站名字,Weinberg 表示是受启发于儿童玩的追逐游戏「duck, duck, goose」,并没有其他深意或隐喻。
支持平台:
一些文章
DuckDuckGo 也支持通过在 URL 上附加参数(parameter)的方式进行高级搜索。例如,下面的 URL:
https://duckduckgo.com/?q=wikipedia&kp=0&kl=cn-zh
将会发起一次关键词为「wikipedia」(q=wikipedia)、不过滤搜索结果(kp=0)、地区范围为中国(kl=cn-zh)的搜索。
与 Google 等具备类似功能的搜索引擎不同的是,DuckDuckGo 不仅支持通过 URL 参数定义搜索的方式,而且支持定义搜索页面的行为(如是否在新标签页中打开链接)和外观(如主题背景)。(可以在 DuckDuckGo 的文档中找到全部可用的参数。)
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.
pip install -U duckduckgo_search
$ ddgs --help
Usage: ddgs [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...
A decorator that creates a command group.
This decorator is used to create a group of commands. The `chain=True`
parameter allows the commands in the group to be chained together, meaning
the output of one command can be used as the input for the next command.
Options:
--help Show this message and exit.
Commands:
answers CLI function to perform a answers search using DuckDuckGo...
images CLI function to perform a images search using DuckDuckGo API.
maps CLI function to perform a maps search using DuckDuckGo API.
news CLI function to perform a news search using DuckDuckGo API.
suggestions CLI function to perform a suggestions search using...
text CLI function to perform a text search using DuckDuckGo API.
translate CLI function to perform translate using DuckDuckGo API.
version A command-line interface command that prints and returns...
videos CLI function to perform a videos search using DuckDuckGo API.
或者
python -m duckduckgo_search --help
# 文字搜索
ddgs text -k "ayrton senna"
# 使用协议搜索文本 (example: Tor Browser)
ddgs text -k "china is a global threat" -p socks5://localhost:9150
# 搜索和下载 pdf 文件
ddgs text -k "russia filetype:pdf" -m 50 -d
# find in es-es region and download pdf files via proxy (example: Tor browser)
ddgs text -k "embajada a tamorlán filetype:pdf" -r es-es -m 50 -d -p socks5://localhost:9150
# 从指定站点搜索和下载 xls 文件
ddgs text -k "sanctions filetype:xls site:gov.ua" -m 50 -d
# 从指定站点搜索和下载任意 doc(x) 文件
ddgs text -k "filetype:doc site:mos.ru" -m 50 -d
# 查找和下载 images
ddgs images -k "yuri kuklachev cat theatre" -m 500 -s off -d
# find in br-br region and download images via proxy (example: Tor browser) in 10 threads
ddgs images -k "rio carnival" -r br-br -s off -m 500 -d -th 10 -p socks5://localhost:9150
# 获取最新的新闻
ddgs news -k "ukraine war" -s off -t d -m 10
# 获取上一天的新闻,并保存到一个 csv 文件
ddgs news -k "hubble telescope" -t d -m 50 -o csv
# 获取答案并保存到一个 json 文件
ddgs answers -k holocaust -o json
Keywords example | Result |
---|---|
cats dogs | Results about cats or dogs |
“cats and dogs” | Results for exact term “cats and dogs”. If no results are found, related results are shown. |
cats -dogs | Fewer dogs in results |
cats +dogs | More dogs in results |
cats filetype:pdf | PDFs about cats. Supported file types: pdf, doc(x), xls(x), ppt(x), html |
dogs site:example.com | Pages about dogs from example.com |
cats -site:example.com | Pages about cats, excluding example.com |
intitle:dogs | Page title includes the word “dogs” |
inurl:cats | Page url includes the word “cats” |
from duckduckgo_search import DDGS
results = DDGS().text('live free or die', region='wt-wt', safesearch='off', timelimit='y', max_results=10)
# Searching for pdf files
results = DDGS().text('russia filetype:pdf', region='wt-wt', safesearch='off', timelimit='y', max_results=10)
# async
results = await AsyncDDGS().text('sun', region='wt-wt', safesearch='off', timelimit='y', max_results=10)
from duckduckgo_search import DDGS
results = DDGS().answers("sun")
# async
results = await AsyncDDGS().answers("sun")
from duckduckgo_search import DDGS
results = DDGS().images(
keywords="butterfly",
region="wt-wt",
safesearch="off",
size=None,
color="Monochrome",
type_image=None,
layout=None,
license_image=None,
max_results=100,
)
# async
results = await AsyncDDGS().images('sun', region='wt-wt', safesearch='off', max_results=20)
from duckduckgo_search import DDGS
results = DDGS().videos(
keywords="cars",
region="wt-wt",
safesearch="off",
timelimit="w",
resolution="high",
duration="medium",
max_results=100,
)
# async
results = await AsyncDDGS().videos('sun', region='wt-wt', safesearch='off', timelimit='y', max_results=10)
from duckduckgo_search import DDGS
results = DDGS().news(keywords="sun", region="wt-wt", safesearch="off", timelimit="m", max_results=20)
# async
results = await AsyncDDGS().news('sun', region='wt-wt', safesearch='off', timelimit='d', max_results=10)
from duckduckgo_search import DDGS
results = DDGS().maps("school", place="Uganda", max_results=50)
# async
results = await AsyncDDGS().maps('shop', place="Baltimor", max_results=10)
from duckduckgo_search import DDGS
keywords = 'school'
# also valid
keywords = ['school', 'cat']
results = DDGS().translate(keywords, to="de")
# async
results = await AsyncDDGS().translate('sun', to="de")
from duckduckgo_search import DDGS
results = DDGS().suggestions("fly")
# async
results = await AsyncDDGS().suggestions('sun')
伊织 2024-03-20
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。