2014-05-01 96 views
2

我很難找出正確的格式來調用谷歌自定義搜索引擎(CSE)的URL來返回XML格式的結果(使用它們的free service進行100次調用天)。我已經建立了一個賬戶和CSE。所以現在我有一個公共的URL https://www.google.com/cse/publicurl?cx=010317493064298903457:5bsx2whinf8來搜索BBC新聞。但我無法從文檔中找出如何開發URL調用來返回XML格式的結果。Google XML/JSON結果 - 使用自定義搜索引擎

https://www.google.com/cse/publicurl?cx=010317493064298903457:5bsx2whinf8&q=lon‌​don&start=0&num=10&output=xml_no_dtd(基於CSE設置選項中提供的代碼)給出了html框架的結果。

http://www.google.com/search?start=0&num=10&q=london&client=google-csbe&output=‌​xml_no_dtd&cx=010317493064298903457:5bsx2whinf8(在XML API examples之後)也返回HTML。

非常感謝一個想法,我錯了。

+0

本頁頂部的註釋表明XML僅適用於付費用戶:https://developers.google.com/custom-sea rch/docs/xml_results –

+0

也許,但[自定義搜索控制API](https://developers.google.com/custom-search/docs/overview)允許用戶每天撥打100個電話。它默認使用同樣可用的json。 – geotheory

+0

從你的文章我以爲你只對XML感興趣..如果JSON是一個選項,我認爲你必須使用這個方法:https://developers.google。com/custom-search/json-api/v1/reference/cse/list –

回答

10

破裂。我必須工作的最小工作URL公式是以下字符串的串聯:

您應該結束了的東西看起來像這樣:

"https://www.googleapis.com/customsearch/v1?q=London+UK&cx=018475493028468909364:ldifwlodnso&key=AOgsDiRlzY7GDCKC5Th7yKutv-7Hd4-IDehl_Sp" 

..結果在json中。

+0

我試過了,但它不起作用 – Prabhash

+0

https://www.googleapis.com/customsearch/v1?q=London+UK&cx=016594182476378821404:09qp1q0wip0&key= AIzaSyDwRQYXGcwjj-HUpxuGZFn9j8VeQ7PzKiY – Prabhash

0

,你也可以通過添加這對您的網址更改格式爲ATOM webfeed: &alt=atom

...它可以讓你您最初請求的XML輸出。

相關問題