Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

2 views
Skip to first unread message

Shagshag13

unread,
Jul 17, 2002, 11:38:54 AM7/17/02
to
hello,

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

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

thanks in advance,

s13.


John Hunter

unread,
Jul 17, 2002, 11:49:40 AM7/17/02
to
>>>>> "Shagshag13" == Shagshag13 <shags...@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')

Paul Brian

unread,
Jul 17, 2002, 11:54:38 AM7/17/02
to
Dear shagshag.....

It can all be done with the google web API

This is an xml-rpc based service that allows you to send through queries and
get back xml formatted results.
Its very impressive, although I am lost for "real world" automated
applications....

You need to register however, to prevent abuse i suppose:

https://www.google.com/accounts/

As for the other search engines, perhaps use urllib to download the pages
and just a simple string.find would result in most answers, with little
effort (or, for masochists, use htmltidy to convert to xhtml, and XPath to
get the bits, or even regular expressions ! )

------------------------------
Paul Brian
(07899) 877 295
paul1...@yahoo.com


"Shagshag13" <shags...@yahoo.fr> wrote in message
news:ah431f$q33vu$1...@ID-146704.news.dfncis.de...

Shagshag13

unread,
Jul 17, 2002, 12:00:50 PM7/17/02
to

"John Hunter" <jdhu...@nitace.bsd.uchicago.edu>

> If you register (free) with google at
>
> http://www.google.com/apis/
>
> you can use pygoogle
>

thanks for that ! i just have registered !

but i'm also looking for others search engines wrappers like altavista or metacrawler, etc.

s13.


John Hunter

unread,
Jul 17, 2002, 12:19:36 PM7/17/02
to
>>>>> "Shagshag13" == Shagshag13 <shags...@yahoo.fr> writes:

Shagshag13> but i'm also looking for others search engines
Shagshag13> wrappers like altavista or metacrawler, etc.

If you are willing to go to the dark side, you may find the WWW:Search
perl mods useful.

John Hunter

Shagshag13

unread,
Jul 17, 2002, 12:32:25 PM7/17/02
to
well, not that time... need python scripts...

but thanks for the advice.

s13.

"John Hunter" <jdhu...@nitace.bsd.uchicago.edu> a écrit dans le message de news: m2y9cag...@mother.paradise.lost...

Marcus Vinicius Laranjeira

unread,
Jul 30, 2002, 11:08:59 AM7/30/02
to

Folks,

I use the mx.DateTime package, and I need to know if in one particular year
has a february with 28 or 29 days ? I don't know how to do that !

Cheers,

Marcus


John Hunter

unread,
Jul 30, 2002, 11:17:46 AM7/30/02
to
>>>>> "Marcus" == Marcus Vinicius Laranjeira <m.lara...@datacraft.com.br> writes:

Marcus> I use the mx.DateTime package, and I need to know if in
Marcus> one particular year has a february with 28 or 29 days ? I
Marcus> don't know how to do that !


Here's one way....

import mx.DateTime

def is_leapyear(year):
try:
d = mx.DateTime.DateTime(year,2,29)
return 1
except mx.DateTime.mxDateTime.RangeError:
return 0

print is_leapyear(2000)
print is_leapyear(2002)


Mark McEahern

unread,
Jul 30, 2002, 11:39:00 AM7/30/02
to
> I use the mx.DateTime package, and I need to know if in one
> particular year
> has a february with 28 or 29 days ? I don't know how to do that !

import mx.DateTime
d = mx.DateTime.DateTimeFrom("2/1/2002")
print d.days_in_month == 28

d2 = d + mx.DateTime.RelativeDateTime(years=2)
print d2.days_in_month == 29

// m
-


Eric Brunel

unread,
Jul 30, 2002, 12:48:55 PM7/30/02
to
Marcus Vinicius Laranjeira wrote:
> Folks,
>
> I use the mx.DateTime package, and I need to know if in one particular
> year has a february with 28 or 29 days ? I don't know how to do that !

A year is a leap year if it can be divided by 4, except if it can be
divided by 100, where it's a leap year only if it can be divided by 400. It
sounds awful to compute, but in Python, it's actually quite simple:

>>> isLeap = lambda x: x % 4 == 0 and (x % 100 != 0 or x % 400 == 0)
>>> isLeap(1980)
1
>>> isLeap(1991)
0
>>> isLeap(2000)
1
>>> isLeap(1900)
0

HTH
--
- Eric Brunel <eric....@pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Andrew McNamara

unread,
Jul 30, 2002, 8:47:34 PM7/30/02
to
>A year is a leap year if it can be divided by 4, except if it can be
>divided by 100, where it's a leap year only if it can be divided by 400. It
>sounds awful to compute, but in Python, it's actually quite simple:
>
>>>> isLeap = lambda x: x % 4 == 0 and (x % 100 != 0 or x % 400 == 0)

Or, if you have a pathological aversion to lambda:

>>> def isLeap(x):
... return x % 4 == 0 and (x % 100 != 0 or x % 400 == 0)
...

>>> isLeap(1980)
1
>>> isLeap(1991)
0
>>> isLeap(2000)
1
>>> isLeap(1900)
0

8-)

--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/

Marcus Vinicius Laranjeira

unread,
Jul 31, 2002, 10:05:52 AM7/31/02
to

All,

I am using the boa constructor, and I need to put the logo of my company in
the wxPanel. This bitmap will be static and it will be there just for
decoration purposes.

Anyone can help me ?

Cheers,

Marcus


Roman Yakovenko

unread,
Jul 31, 2002, 11:57:22 AM7/31/02
to
Hi. One of the basic controls (in basic control panel) is static bitmap.
You can put this control on panel. Use "Bitmap" property to set desired bitmap.

Also you may insert you bitmap to code, see img2py.py file in wxPython\tools folder.

Roman.


All,

Cheers,

Marcus


--
http://mail.python.org/mailman/listinfo/python-list

Michael Gilfix

unread,
Jul 31, 2002, 11:20:15 AM7/31/02
to
Since someone else already gave you pointers, just a suggestion:
look at the numerous examples that come with wxPython. There should be
a static bitmap example there that would be most educational.

-- Mike

On Wed, Jul 31 @ 11:05, Marcus Vinicius Laranjeira wrote:
>
>
> All,
>
> I am using the boa constructor, and I need to put the logo of my company in
> the wxPanel. This bitmap will be static and it will be there just for
> decoration purposes.
>
> Anyone can help me ?
>
> Cheers,
>
> Marcus
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list

`-> (m.laranjeira)

--
Michael Gilfix
mgi...@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html

John Baxter

unread,
Jul 31, 2002, 11:57:04 PM7/31/02
to
In article <ai6fls$8kl$1...@wanadoo.fr>,
Eric Brunel <eric....@pragmadev.com> wrote:

> A year is a leap year if it can be divided by 4, except if it can be
> divided by 100, where it's a leap year only if it can be divided by 400. It
> sounds awful to compute, but in Python, it's actually quite simple:

With ongoing discussion of a potential y4k exception exception exception
(not leap year) to adjust just a bit more finely. For most purposes, we
have time to deal with that one.

--John

Steve Holden

unread,
Aug 2, 2002, 1:39:26 PM8/2/02
to
"John Hunter" <jdhu...@ace.bsd.uchicago.edu> wrote in message
news:mailman.1028042640...@python.org...

Another way is to RTFM :-) From the mx.DateTime documentation on DateTime
instance variables:

is_leapyear
Returns 1 iff the instances value points to a leap year in the Gregorian
calendar.
regards
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------

0 new messages