Search code examples
phpjavascripthtmlurltitle

Google API | URL to site title


For example to get the favicon of a site I can use http://www.google.com/s2/favicons?domain= and fill in the domain. Google returns the favicon. I would also like to pull the title.

I know that I could parse the title from the html on the server side...or I could use javascript document.title on the client side. But I don't want to have to download the whole site.

I used the favicon example b.c. it was a good example of how you have data about a site available on the web with out having to do any "heavy lifting"

There must be a similar for the title. Essentially I want to match a URL to title.


Solution

  • You can make use of the Google custom search API to get the title of a website. Just search for "info:siteurl" and grab the title of the first request. I don't know exactly what you want to do, but it allows for 100 requests a day.

    See details of the API here: http://code.google.com/apis/customsearch/v1/reference.html