我正在使用Bing SearchAPI2.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搜索培根,网址是:
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寻找的结果)。
为什么会这样呢?不管怎么说,这附近有吗?
发布于 2012-01-15 22:49:14
是的,因为这个事实,必应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"));
发布于 2011-05-05 00:37:56
看起来API请求实际上并不是在请求信息。嗯,是的,但不完全是。例如,从必应搜索;"search?q=bacon&go=&form“注意它中的培根一词。在API请求中,这似乎没有以任何方式被解析。甚至不是作为一个十六进制值。我相信问题就在这里。
发布于 2012-01-31 06:55:21
也许有个问题,现在已经解决了.
目前,如果我尝试以下查询,根据必应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
https://stackoverflow.com/questions/5804779
复制相似问题