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 2 1317
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bdawg |
last post by:
what i want to do is create several radio buttons and a textbox for
searching purposes. the search will perform a search depending on
which button the user selects.
here is what i have now:
...
|
by: Frances Del Rio |
last post by:
if (parent.frames.main.location == 'mediaselect.html') {
I have a very simple frameset, name of frame where I'm checking is
'main'... why is this not working? I mean this is correct syntax,...
|
by: Paul |
last post by:
HI! I get an error with this code.
<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>
Basicly I want my iframe to have a default page if the user enters in...
|
by: Paul |
last post by:
HI! I have a script that does not seem to work. can someone tell me what I
am doing wrong here?
<script language="JavaScript">
function firefoxautofix(){
parent.window.resizeBy(-1,-1)...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: Midnight Java Junkie |
last post by:
Dear Colleagues:
I feel that the dumbest questions are those that are never asked. I have
been given the opportunity to get into .NET. Our organization has a
subscription with Microsoft that...
|
by: Viken Karaguesian |
last post by:
Hello all,
On occasion I want to open hyperlinks (images, etc.) in a new window. In the
past, I've used target="_blank" to open the link in a new window. However,
using the "target" attribute...
|
by: Jeff Gardner |
last post by:
Greetings:
I am attempting to get conditional output based on POSTed form data.
If the posted value is either the key or value of an array, $x=key and
$q=foo. elseif it is neither key nor...
|
by: garfy |
last post by:
Hi
i get this error in validation
Line 22 column 6: document type does not allow element "title" here.
<title>Seo Web Design Los Angeles - Web Design And Search Engine Optimization L
...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |