how to ask google, altavista or another search engine...

John Hunter jdhunter at nitace.bsd.uchicago.edu
Wed Jul 17 11:49:40 EDT 2002


>>>>> "Shagshag13" == Shagshag13  <shagshag13 at yahoo.fr> writes:

    Shagshag13> hello, i'm looking for a python script able to ask to
    Shagshag13> a web search engine (google, altavista or another
    Shagshag13> search engine) and/or able to parse a result page.

    Shagshag13> any other helps / advices / urls are welcome...

    Shagshag13> thanks in advance,

    Shagshag13> s13.

If you register (free) with google at 

http://www.google.com/apis/

you can use pygoogle


http://diveintomark.org/projects/#pygoogle

Here's a simple example script (add your own license key)

import google

# Get your own from http://www.google.com/apis/
google.LICENSE_KEY = 'youRliCenseKEYHere'
data = google.doGoogleSearch('python')

# Search time
#print data.meta.searchTime

# Meta attributes
#print dir(data.meta)

print 'Found %d results' % len(data.results)

for result in data.results:
    print 'Title: ', result.title
    print 'URL: ', result.URL
    print 'Summary: ', result.snippet
    print
    
# Result attributes
#print dir(result)

# Spelling suggestion:
#print google.doSpellingSuggestion('pithon')



More information about the Python-list mailing list