我应该使用哪些参数才能仅使用 bing 2.0 API 从 abcd.com 网站获取搜索结果?我正在尝试以 JSON 格式获取结果。有人可以帮忙吗?
问问题
2769 次
2 回答
2
给大众的新鲜代码
$query = array
(
'AppId' => <API_KEY>,
'sources' => 'Web',
'query' => 'site:www.tipografix.ro '.$keywords,
'Version' => '2.0',
'Options' => 'EnableHighlighting',
'Web.Count' => $per_page,
'Web.Offset' => $page_num,
'Web.Options' => 'DisableHostCollapsing DisableQueryAlterations'
);
$request = 'http://api.bing.net/json.aspx?'.http_build_query($query);
$response = file_get_contents($request);
$jsonobj = json_decode($response);
于 2011-06-17T10:53:47.340 回答
0
不确定 API 的 JSON 格式是如何工作的,但在查询参数中放入“site:abcd.com bacon”,其中bacon是您的原始查询。
我使用的是 XML 格式,所以如果我向以下地址发送请求:
http://api.search.live.net/xml.aspx?Appid=________&query=site%3Aabcd.com+bacon&sources=web&web.count=5&web.offset=0
于 2011-04-27T13:27:15.707 回答