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.
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
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')
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...
thanks for that ! i just have registered !
but i'm also looking for others search engines wrappers like altavista or metacrawler, etc.
s13.
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
but thanks for the advice.
s13.
"John Hunter" <jdhu...@nitace.bsd.uchicago.edu> a écrit dans le message de news: m2y9cag...@mother.paradise.lost...
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
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)
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
-
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
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/
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
Also you may insert you bitmap to code, see img2py.py file in wxPython\tools folder.
Roman.
All,
Cheers,
Marcus
-- 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
> 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
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/
-----------------------------------------------------------------------