Google Blogoscoped

Friday, January 9, 2004

Google Web API with Python

Python is a very elegant language for server or desktop scripting. Mark Pilgrim developed an easy to use module to integrate the Google Web API. "Google with Python" is an online demo of the following Python source code, which uses PyGoogle (all scripts were put to the cgi-bin directory, and permissions 755 were chosen):


import sys
import string
import codecs
import google

print 'Content-type: text/htmln'

print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
print ' "DTD/xhtml1-strict.dtd">'
print '<html xmlns="" xml:lang="en">'
print '<head>'
print '    <meta http-equiv="Content-Type" content="text/html; CHARSET=UTF-8" />'
print '    <title>Google with Python</title>'
print '    <link rel="stylesheet" href="/style/python-google.css"'
print ' type="text/css" media="screen, handheld" />'
print '</head>'
print '<body>'

print '<h1>Google with Python</h1>'

sys.stdout = codecs.lookup('utf-8')[-1](sys.stdout)

query = "Python Google"
data = google.doGoogleSearch(query)

print '<p><strong>1-10 of "' + query + '" total results for '
print str(data.meta.estimatedTotalResultsCount) + '</strong></p>'

for result in data.results:
    title = result.title
    title = title.replace('<b>', '<strong>')
    title = title.replace('</b>', '</strong>')

    snippet = result.snippet
    snippet = snippet.replace('<b>','<strong>')
    snippet = snippet.replace('</b>','</strong>')
    snippet = snippet.replace('<br>','<br />')

    print '<h2><a href="' + result.URL + '">' + title + '</a></h2>'
    print '<p>' + snippet + '</p>'

print '</body>'
print '</html>'

Also see: Google Web API with PHP

Windows Desktop Google

GAPIS (the “Google API Search Tool”) is a Windows-based search engine. The program is free, though you need to have your own Google license key.

Yahoo Buzz

Did you know that you can find the top Yahoo searches at the Yahoo! Buzz Index? You can also grab the buzz via RSS newsfeeds. Also available as feed: the most-emailed stories.

Whois - New Google Feature

A great new Google feature has been added: type e.g. “whois” (no quotes) to find the owner of a domain.
[Via Abakus]


Blog  |  Forum     more >> Archive | Feed | Google's blogs | About


This site unofficially covers Google™ and more with some rights reserved. Join our forum!