469,929 Members | 1,441 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

what's wrong here? (search script)

Dear Someone:

I have written a script that accesses the googleAPI through
pygoogle and saves each of the ten documents as a .txt file by using a
specific function for each respective file type (.doc, .pdf, .html) to
convert it to such. Everything works fine, except that I am trying to
make it search and return another result in the event that a file type
other than .doc, .pdf, .html, or .txt comes up. Python is new to me
and I'm not sure why my method doesn't work. I'd really appreciate any
advice; here is the relevant code:

def searchhelper(words, start=0, max=10):
data = google.doGoogleSearch(words)
objlist = data.results
urllist = map((lambda x: x.URL), objlist)
return urllist
def searchhelper2(initwords, urls, counter):
for url in urls:
if findinlink(url, 'pdf'): # all these functions are defined
elsewhere,
convertpdf(url) # fbut they definitely are working properly
elif findinlink(url, 'htm'):
converthtml(url)
elif findinlink(url, 'txt'):
urllib.urlretrieve(url, parse(x))
elif findinlink(url, 'doc'):
convertdoc(url)
elif not findinlink(url, '.'):
converthtml(url)
else:
urllist = urls[counter + 1:] + searchhelper(initwords, 11 + counter,
1) # (I'm
searchhelper2(initwords, urllist, counter + 1)# assuming this is
where I have #
erred; however, I'm not sure)
def search(initwords):
urllist = searchhelper(initwords)
searchhelper2(initwords, urllist, 0)

Thanks,
Brendan

Jul 6 '06 #1
2 1185
I figured it out. Is there any way to delete your own posts?

Brendan Fay wrote:
Dear Someone:

I have written a script that accesses the googleAPI through
pygoogle and saves each of the ten documents as a .txt file by using a
specific function for each respective file type (.doc, .pdf, .html) to
convert it to such. Everything works fine, except that I am trying to
make it search and return another result in the event that a file type
other than .doc, .pdf, .html, or .txt comes up. Python is new to me
and I'm not sure why my method doesn't work. I'd really appreciate any
advice; here is the relevant code:

def searchhelper(words, start=0, max=10):
data = google.doGoogleSearch(words)
objlist = data.results
urllist = map((lambda x: x.URL), objlist)
return urllist
def searchhelper2(initwords, urls, counter):
for url in urls:
if findinlink(url, 'pdf'): # all these functions are defined
elsewhere,
convertpdf(url) # fbut they definitely are working properly
elif findinlink(url, 'htm'):
converthtml(url)
elif findinlink(url, 'txt'):
urllib.urlretrieve(url, parse(x))
elif findinlink(url, 'doc'):
convertdoc(url)
elif not findinlink(url, '.'):
converthtml(url)
else:
urllist = urls[counter + 1:] + searchhelper(initwords, 11 + counter,
1) # (I'm
searchhelper2(initwords, urllist, counter + 1)# assuming this is
where I have #
erred; however, I'm not sure)
def search(initwords):
urllist = searchhelper(initwords)
searchhelper2(initwords, urllist, 0)

Thanks,
Brendan
Jul 6 '06 #2
Brendan Fay wrote:
I figured it out. Is there any way to delete your own posts?

Brendan Fay wrote:
>Dear Someone:

I have written a script that accesses the googleAPI through
pygoogle and saves each of the ten documents as a .txt file by using a
specific function for each respective file type (.doc, .pdf, .html) to
convert it to such. Everything works fine, except that I am trying to
make it search and return another result in the event that a file type
other than .doc, .pdf, .html, or .txt comes up. Python is new to me
and I'm not sure why my method doesn't work. I'd really appreciate any
advice; here is the relevant code:

def searchhelper(words, start=0, max=10):
data = google.doGoogleSearch(words)
objlist = data.results
urllist = map((lambda x: x.URL), objlist)
return urllist
def searchhelper2(initwords, urls, counter):
for url in urls:
if findinlink(url, 'pdf'): # all these functions are defined
elsewhere,
convertpdf(url) # fbut they definitely are working properly
elif findinlink(url, 'htm'):
converthtml(url)
elif findinlink(url, 'txt'):
urllib.urlretrieve(url, parse(x))
elif findinlink(url, 'doc'):
convertdoc(url)
elif not findinlink(url, '.'):
converthtml(url)
else:
urllist = urls[counter + 1:] + searchhelper(initwords, 11 + counter,
1) # (I'm
searchhelper2(initwords, urllist, counter + 1)# assuming this is
where I have #
erred; however, I'm not sure)
def search(initwords):
urllist = searchhelper(initwords)
searchhelper2(initwords, urllist, 0)

Thanks,
Brendan
Instead of deleting the previous post, you should post the solution for
all to learn from.

desNotes
Jul 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bdawg | last post: by
14 posts views Thread by Frances Del Rio | last post: by
4 posts views Thread by Paul | last post: by
121 posts views Thread by typingcat | last post: by
8 posts views Thread by Midnight Java Junkie | last post: by
44 posts views Thread by Viken Karaguesian | last post: by
6 posts views Thread by Jeff Gardner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.