Does Pygoogle allows for advanced search options?

Stefan Sonnenberg-Carstens stefan.sonnenberg at pythonmeister.com
Sun Nov 21 05:51:11 EST 2010


Am 21.11.2010 11:01, schrieb Petar Milin:
>
> On 20/11/10 22:34, Chris Rebert wrote:
>> On Thu, Nov 18, 2010 at 3:26 AM, neocortex<pmilin at gmail.com>  wrote:
>>>> 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"
>>>> onhttp://code.google.com/apis/websearch/docs/reference.html, and
>>>> lines 68&  102 of pygoogle.py.
>>>  From those lines, it can be concluded that lr=lang_?? is not
>>> supported, unfortunately.
>> Right; that's why I said "you could implement that feature". Pretty
>> easily it would seem.
> Thanks for believing in me ( ;-) ), but I am a newbie in Python world, 
> although with some experience in other prog. languages.
> So, if I read pygoogle.py well, I sould add lr parameter in init and 
> then after lines 68 and 102?
Correct.
I just did not read source code enough to realize the parameter is needed
twice. You just could hack that out, too :-)
Normally (what is normal, anyway ?) it's good practice to create an
contructor (__init__) in python which has the most common options
as keyword arguments and default values assigned, like so:

class Foo:
     def __init__(self,lr='lang_en',url='http://some.of.this'):
         self.lr = lr
         self.url = url
     ...
>
> Thanks again! You guys here are very kind and helpful!
> Best,
> Petar
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pygoogle.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20101121/0332e3db/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stefan_sonnenberg.vcf
Type: text/x-vcard
Size: 223 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20101121/0332e3db/attachment.vcf>


More information about the Python-list mailing list