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

我正在使用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搜索培根,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的结果).
为什么是这样?有没有办法解决

是的,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"));

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...