Bing: search - match only exact literal strings?
Asked Answered
B

3

7

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?

Byebye answered 17/4, 2011 at 21:44 Comment(4)
Have you googled this yet?Loganloganberry
@cohensh, are you being ironic?Curlpaper
Yes, I have no idea how to help so I make hopefully comments instead.Loganloganberry
I googled this question, this thread is the first result @LoganloganberryAutocorrelation
C
4

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

Constantan answered 4/5, 2011 at 0:32 Comment(4)
Nope, still not working on Bing. You can test it for yourself using the standard Bing website. When you search for +"www.gebouw.nl" , you also get : www.ge-bouw.nl , etc.Byebye
When I go to bing.com/search?q=%2Bwww.gebouw.nl&form=APIPA1 I see 3 results: 2 from www.gebouw.nl and 1 from loopingrecursion.com which scraped this question.Constantan
The plus sign seems to work for me. Regardless of if you have quotes or not around your search term.Trisoctahedron
I'll note that in 2022, using the + in front of a quoted string did work as the solution for me, finding something that the Bing site would not find if I did NOT use the +. Granted, the original question here was about the API, but this helped me in using the bing.com site--and may help others, so thanks. (And I even tried the example Dylan offered above, and that too worked and did not show the ge-bouw.nl...but I realize that comment was from 11 years ago and things could have changed, in bing or about that site, affecting it appearing in the results.)Slovakia
O
1

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."

Orta answered 2/11, 2015 at 16:58 Comment(0)
L
-1

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"])
Launcher answered 11/4, 2023 at 6:3 Comment(1)
Please refer to the below documentation learn.microsoft.com/en-us/azure/cognitive-services/…Launcher

© 2022 - 2024 — McMap. All rights reserved.