Does Pygoogle allows for advanced search options?

Chris Rebert clp2 at rebertia.com
Thu Nov 18 09:28:03 CET 2010


On Wed, Nov 17, 2010 at 11:54 PM, neocortex <pmilin at gmail.com> wrote:
> Hello All,
> Can anyone help me with the Pygoogle:
> from pygoogle import pygoogle

You're apparently talking about http://code.google.com/p/pygoogle/
rather than http://pygoogle.sourceforge.net/ ; the former appears to
have "borrowed" the latter's name without permission. Oi!

> word = u'something'
> request_word = word.encode('utf-8')
> request = ('%s+site:.edu' % request_word)
> g = pygoogle(request)
> g.get_result_count()
>
> Now, I realized that domain restriction works (site:.edu etc.), but I
> would like to be able to control for language too. Is that possible
> with the Pygoogle? If not, how can I make that happen?

The library doesn't seem to have built-in support for filtering by
language (and Google lacks a search query-string-based operator for
that), but it looks like you could implement that feature by adding an
"lr" parameter with an appropriate value to the query `args`
dictionary. See the "lr?" entry under "Web Search Specific Arguments"
on http://code.google.com/apis/websearch/docs/reference.html , and
lines 68 & 102 of pygoogle.py.

Cheers,
Chris
--
Research for random person => too much idle time
http://blog.rebertia.com



More information about the Python-list mailing list