Python Script to get Info from Site not working
Steve Holden
steve at holdenweb.com
Thu Mar 11 07:37:20 EST 2010
Jimbo wrote:
> On Mar 11, 12:38 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> En Wed, 10 Mar 2010 20:06:41 -0300, Jimbo <nill... at yahoo.com> escribió:
>>
>>> I found a semi Python & internet tutorial here if anyone else would
>>> like ithttp://www.upriss.org.uk/python/session6.html
>>> My script is meant to find which radio button is selected & tell me
>>> that. But it just keeps saying "No Drink Selected!"
>> Are you sure? From the code you posted, the message should read "You need
>> to select a drink!", not that one.
>
>> Replace the last line with something like this, to see what you are
>> getting exactly:
>>
>> print("Sorry, no %r (%r) available." % (
>> drink,
>> cgi.escape(repr(type(drink)))))
>>
>> BTW, which Python version are you using? The tutorial you linked to is
>> aimed at Python 2.x, but your print syntax suggests you're using Python 3.x
>>
>> --
>> Gabriel Genellina
>
> Yeah that("You need to select a drink!") was the string I was getting
> but I should be getting hot chocolate or something else(which ever one
> I have selected)
>
> I am using 3.x, do you think I should be using something else? Also
> the your code I put in does the some thing, just now it says "Sorry no
> none drink available" all the time.
It may not seem like it, but you *are* making progress here (of a sort).
>From the information you have given us so far it appears that your call
to form.getvalue() is returning None (which is of type <type 'NoneType'>
- your browser is probably not displaying this because it sees it as a
bogus HTML tag.
Perhaps you haven't yet realised the importance of exact copy-and-paste
here. What I'd like you to do is change the line
drink = form.getvalue("drink")
to
drink = form.getfirst("drink", "No drink selected")
then have you browser display the HTML source of the response page your
program is returning and paste that into a reply to this mail.
You might also want to take a look at
http://docs.python.org/3.1/library/cgi.html
for further information about the Python library your are trying to use.
In particular I'd recommend heeding its advice about use of the cgitb
module.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list
mailing list