Bing api 使用 python 进行网络搜索的高级运算符
Bing api Advanced operator for web search using python
我想使用高级运算符来过滤我的搜索结果。搜索结果应仅包含 PDF。我添加了高级运算符(文件类型:pdf)。不过好像不行。
subscription_key = "My_ACCESS_KEY"
assert subscription_key
search_url = "https://api.cognitive.microsoft.com/bing/v7.0/search"
search_term = "NASA"
import requests
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term, "filetype":"pdf", "responseFilter":"Webpages", textDecorations":True, "textFormat":"HTML"}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
我不知道如何使用高级运算符 (filetype:pdf) 来过滤搜索结果。
任何人都可以建议我如何使用它吗?。
谢谢
我刚刚尝试了他们文档中的示例代码。我添加了 filetype
as url 查询参数并且似乎有效。
import requests
subscription_key = "..."
assert subscription_key
search_url = "https://api.cognitive.microsoft.com/bing/v5.0/search"
search_term = "Machine%20Learning&filetype=pdf"
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
print(search_results)
我想使用高级运算符来过滤我的搜索结果。搜索结果应仅包含 PDF。我添加了高级运算符(文件类型:pdf)。不过好像不行。
subscription_key = "My_ACCESS_KEY"
assert subscription_key
search_url = "https://api.cognitive.microsoft.com/bing/v7.0/search"
search_term = "NASA"
import requests
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term, "filetype":"pdf", "responseFilter":"Webpages", textDecorations":True, "textFormat":"HTML"}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
我不知道如何使用高级运算符 (filetype:pdf) 来过滤搜索结果。
任何人都可以建议我如何使用它吗?。
谢谢
我刚刚尝试了他们文档中的示例代码。我添加了 filetype
as url 查询参数并且似乎有效。
import requests
subscription_key = "..."
assert subscription_key
search_url = "https://api.cognitive.microsoft.com/bing/v5.0/search"
search_term = "Machine%20Learning&filetype=pdf"
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
params = {"q": search_term}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
print(search_results)