使用 Bing.com 和 Bing Search API 的不同结果

发布于 2024-11-03 14:57:16 字数 774 浏览 3 评论 0原文

我正在使用 Bing Search API 2.0 (XML) & PHP 检索结果。
但在运行某些查询时,API 不会返回 Bing.com 会返回的(相同)结果。

当我发送此请求时:(这是使用 API)

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

我得到 0 个结果。

但是,如果我访问 Bing.com 并搜索 bacon,URL 将是:

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

因此,如果我将 API 查询替换为该 URL,如下所示:

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

我应该再次得到 0 个结果,对吧?

不,我得到 1 个结果。 (我使用 API 寻找的结果)。
这是为什么呢?这附近还有吗?

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?

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

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

发布评论

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

评论(3

讽刺将军 2024-11-10 14:57:16

是的,Bing API 完全是脑死亡并且完全无用,因为这个事实。

但幸运的是,屏幕抓取是微不足道的:

<?

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"));

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"));
人海汹涌 2024-11-10 14:57:16

看起来 API 请求实际上并不是在请求信息。嗯,确实如此,但又不完全是。例子;
来自 bing 搜索; “search?q=bacon&go=&form” 注意其中的“bacon”一词。
这似乎不会在 API 请求中以任何方式进行解析。甚至不是十六进制值。我认为问题就在这里。

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.

送你一个梦 2024-11-10 14:57:16

也许存在一个问题,现已解决...

目前,如果我尝试以下查询 根据 Bing API 2.0 MSDN 制作,它们都返回相同的单个结果:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文