Question

I'm having difficulty figuring out the right format for URL calls to a Google Custom Search Engine (CSE) to return results in XML (using their free service for 100 calls per day). I've set up an account and CSE. So now I have a public URL https://www.google.com/cse/publicurl?cx=010317493064298903457:5bsx2whinf8 to search BBC news. But I can't figure out from the documentation how to develop the URL call to return results in XML format..

https://www.google.com/cse/publicurl?cx=010317493064298903457:5bsx2whinf8&q=lon‌​don&start=0&num=10&output=xml_no_dtd (based on the code provided in the CSE setup options) gives results in html frame.

http://www.google.com/search?start=0&num=10&q=london&client=google-csbe&output=‌​xml_no_dtd&cx=010317493064298903457:5bsx2whinf8 (following the XML API examples) also returns HTML.

Very grateful for an idea where I'm going wrong.

Was it helpful?

Solution

Cracked. The minimum working URL formula I've got to work is a concatenation of the following strings:

You should end up with something looking like this:

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

.. with results in json.

OTHER TIPS

you can also change format into an ATOM webfeed by adding this to your url: &alt=atom

... which gets you the XML output you originally requested.

Google's XML API reference says:

This page refers to the XML version of the Custom Search API, which is available only to Google Site Search customers.

Google Site Search says:

Google has discontinued sale/renewal of the Google Site Search since Apr 1 2017. The product will be completely shut down by April 1, 2018

This can help, but is still in alpha: http://serp-spider.github.io/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top