【发布时间】:2011-04-26 17:12:50
【问题描述】:
我应该使用哪些参数才能仅使用 bing 2.0 API 从 abcd.com 网站获取搜索结果?我正在尝试以 JSON 格式获取结果。有人可以帮忙吗?
【问题讨论】:
我应该使用哪些参数才能仅使用 bing 2.0 API 从 abcd.com 网站获取搜索结果?我正在尝试以 JSON 格式获取结果。有人可以帮忙吗?
【问题讨论】:
为大众提供新代码
$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);
【讨论】:
不确定 API 的 JSON 格式如何工作,但在 query 参数中放入“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
【讨论】: