Bing:搜索 - 仅匹配精确的文字字符串?

发布于 2024-11-01 22:41:32 字数 224 浏览 4 评论 0原文

我正在使用 PHP 和 Bing API 来搜索某些域名。 我只想要完全匹配的结果。

无论如何,Bing 返回的结果并不完全匹配。

当我搜索:

“www.gebouw.nl”

时,我有时也会得到类似“www.gprgebouw.nl”的结果

有没有办法告诉 Bing 仅搜索完全匹配?

I'm using PHP and the Bing API to search for certain domainnames.
I want only the results that are an EXACT match.

Somehow Bing returns results that do not match exactly.

When I search for :

"www.gebouw.nl"

I sometimes also get results like "www.gprgebouw.nl"

Is there a way to tell Bing to search only for EXACT matches?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

命比纸薄 2024-11-08 22:41:32

Try adding a plus sign to your query. e.g. +www.gebouw.nl which is %2Bwww.gebouw.nl when url encoded

http://www.google.com/support/websearch/bin/answer.py?answer=136861

http://onlinehelp.microsoft.com/en-us/bing/ff808438.aspx

メ斷腸人バ 2024-11-08 22:41:32

WebSearchOptions='DisableQueryAlterations' 可能是这个问题的关键吗?
根据 API 文档,“DisableQueryAlterations 阻止 Bing 更改查询字符串。此类更改可能是为了纠正原始查询字符串中明显的拼写错误。”

Could WebSearchOptions='DisableQueryAlterations' be the key to this?
As per API documentation, "DisableQueryAlterations Prevents Bing from altering the query string. Such alteration may have been done to correct apparent spelling error in the original query string."

栀子花开つ 2024-11-08 22:41:32

制定查询:

要搜索特定域的结果,请使用 site: 运算符,后跟域名。例如,如果您只想在域“example.com”上搜索“cats”,您的查询将如下所示:
cats site:example.com

示例 Python 代码如下

import requests

subscription_key = "YOUR_SUBSCRIPTION_KEY"
search_term = "cats site:example.com"
endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search"

headers = {
    "Ocp-Apim-Subscription-Key": subscription_key
}

params = {
    "q": search_term,
    "count": 50,  # number of results per request, up to 50
    "offset": 0,  # index of the first result to return, useful for pagination
    "mkt": "en-US"  # market to use for the search, for example, "en-US"
}

response = requests.get(endpoint, headers=headers, params=params)
search_results = response.json()

for result in search_results["webPages"]["value"]:
    print(result["name"], result["url"])

Formulate your query:

To search for results from a specific domain, use the site: operator followed by the domain name. For example, if you want to search for "cats" only on the domain "example.com", your query would look like this:
cats site:example.com

Sample Python code is below

import requests

subscription_key = "YOUR_SUBSCRIPTION_KEY"
search_term = "cats site:example.com"
endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search"

headers = {
    "Ocp-Apim-Subscription-Key": subscription_key
}

params = {
    "q": search_term,
    "count": 50,  # number of results per request, up to 50
    "offset": 0,  # index of the first result to return, useful for pagination
    "mkt": "en-US"  # market to use for the search, for example, "en-US"
}

response = requests.get(endpoint, headers=headers, params=params)
search_results = response.json()

for result in search_results["webPages"]["value"]:
    print(result["name"], result["url"])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文