10

I'm using the Bing Search API 2.0 (XML) & PHP to retreive results.
But when running some queries, the API doesn't return the (same) results Bing.com would.

When I send this request: (This is using the API)

http://api.search.live.net/xml.aspx?Appid=__________&query=3+ts+site%3Amycharity.ie/charity&sources=web&web.count=10&web.offset=0

I get 0 results.

But if I go to Bing.com and search for bacon the URL would be:

http://www.bing.com/search?q=bacon&go=&form=QBRE&filt=all&qs=n&sk=&sc=8-5

So If I take I substitute in my API query into this URL like so:

http://www.bing.com/search?q=3+ts+site%3Amycharity.ie/charity&go=&form=QBRE&filt=all&qs=n&sk=&sc=8-5

I should get 0 results again, right?

No, I get the 1 result. (The result I was looking for with the API).
Why is this? Is there anyway around this?

Adam Lynch
  • 3,341
  • 5
  • 36
  • 66
  • 2
    Upvoted for similar issue. I'm seeing the exact same thing as well, similar site specific query as well. I've asked this question and keep receiving the response from bing.com folks that "It's impossible since it all uses the same code base." – Alex S. May 01 '11 at 01:13
  • I got the same issue. Using the API I constantly miss the first result. Does anybody have a solution? It should be something related to the API version we use. Check this website: azbul.net They use bing as well but and the results are the same as on bing.com. Haran –  Sep 28 '11 at 12:43
  • I have a similar problem in that the search results are not the same between the Api versus Bing.com. The Api doesn't return as many results and it returns items that the Bing.com does not. I found the following forum post in the Bing community. Maybe someday one of these will get an answer and get the problem fixed. [Bing API Forum Post](http://www.bing.com/community/developer/f/12254/t/669027.aspx) – user392139 Jan 13 '12 at 21:08
  • Bing just posted a general sort of message, that they fixed API 2.0, Search API. It wasn't *real* specific, but you might want to have a look: http://www.bing.com/community/developer/f/12254/t/671908.aspx – Ellie Kesselman Jan 29 '12 at 17:54
  • Same here, in 2017! :( – Giovanni Bitliner Dec 04 '17 at 00:27

3 Answers3

3

Yes the Bing API is totally brain dead and utterly useless because of this fact.

But, luckily, screen scraping is trivial:

<?

function searchBing($search_term)
{       
    $html = file_get_contents("http://www.bing.com/search?q=".urlencode($search_term)."&go=&qs=n&sk=&sc=8-20&first=$start&FORM=QBLH");

    $doc = new DOMDocument();
    @$doc->loadHtml($html);
    $x = new DOMXpath($doc);

    $output = array();

    // just grab the urls for now
    foreach ($x->query("//div[@class='sb_tlst']//a") as $node)          
    {

        $output[] = $node->getAttribute("href");

    }
    return $output;
}

print_r(searchBing("bacon"));
Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
  • This code works like a charm... However I couldnt succeed to get the results count at `//*[@id='count']`... I would appreciate the help =) – Enissay Jul 26 '13 at 01:22
0

Doesnt look like the API request is actually requesting the information. Well, it is, but not quite. Example; from the bing search; "search?q=bacon&go=&form" Note the word bacon in it. This doesnt appear to be parsed in any way in the API request. Not even as a hex value. I believe that herein lies the problem.

McAzzaMan
  • 411
  • 1
  • 4
  • 9
  • 2
    Wrong. In my example of using Bing.com I say `if I go to Bing.com and search for bacon the URL would be` i.e. just typing "bacon" into the textfield and clicking search. The URL then `http://www.bing.com/search?q=bacon&go=&form=QBRE&filt=all&qs=n&sk=&sc=8-5` is the URL Bing.com sends back to me. – Adam Lynch May 05 '11 at 08:07
0

Perhaps there was an issue, which is now fixed...

Currently, if I'm trying the following queries made according to the Bing API 2.0 MSDN they all return the same single result:

http://www.bing.com/search?q=3+ts+site%3Amycharity.ie/charity&go=&form=QBRE&filt=all&qs=n&sk=&sc=8-5

http://api.bing.net/xml.aspx?Appid=______7&query=3+ts+site%3Amycharity.ie/charity&sources=web

http://api.bing.net/json.aspx?Appid=_______&query=3+ts+site%3Amycharity.ie/charity&sources=web
Massimiliano
  • 16,770
  • 10
  • 69
  • 112