4
我需要從Bing中提取搜索結果。有沒有可用的Java代碼來實現這一目標?如何在Java中使用Bing搜索API
我需要從Bing中提取搜索結果。有沒有可用的Java代碼來實現這一目標?如何在Java中使用Bing搜索API
This MSDN forum thread有很多答案和例子。
此外,當您購買或訂閱Azure上的數據集時,他們有一個java示例。下面是一個例子
轉到odata4j網站和 下載最新版本。
將odata4j-clientbundle-x.x.jar添加到您的Java構建路徑。
您可以使用下面的代碼來調用該服務。
ODataConsumer c = ODataConsumers
.newBuilder("https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/")
.setClientBehaviors(OClientBehaviors.basicAuth("accountKey", "{your account key here}"))
.build();
OQueryRequest<OEntity> oRequest = c.getEntities("Web")
.custom("Query", "stackoverflow bing api");
Enumerable<OEntity> entities = oRequest.execute();
很難找到一個工作的例子,這是一個完美的工作!謝謝。 – YMomb
請記住編碼您的查詢並在查詢的開頭和結尾添加'''。 'String query = URLEncoder.encode(''stackoverflow bing api'「,」UTF-8「);'參見http://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters更多細節。 –