Hello I am asking what is probably a very easy thing to do but I cannot find a tutorial on how to do it anywhere. [b]I want to use a Python script to get information from a webpage. [/b]
I found a semi Python & internet tutorial here if anyone else would like it http://www.upriss.org.uk/python/session6.html I would like to create a python script that gets a value from a set of radio buttons on a HTML page & tell me which one is selected. I have 3 radio buttons: Tea, Coffee, Hot Chocolate & a Submit button My script is meant to find which radio button is selected & tell me that. But it just keeps saying "No Drink Selected!" Can you help me figure out how to fix this. FYI: My Python script & my HTML page are both saved in the same directory. And I made the webpage using Notepad++, I open the webpage in Interent Explorer & I made the Python Script in Idle. Python Script: [code]# Practice 9 CGI ######### don't change the following three lines: ########### import cgi print("Content-Type: text/html\n") form = cgi.FieldStorage() ## add a form.getvalue for each of the names in your form: ## drink = form.getvalue("drink") ########## start of HTML code ########### print(""" <html> <head> <title>What would you like to drink</title> </head> <body> <h4>Your drink: </h4><p> """) ############ end of HTML code ############# if drink == "tea": print("You requested tea.") elif drink == "coffee": print("You requested coffee.") elif drink == "hot chocolate": print ("You requested hot chocolate.") else: print ("You need to select a drink!") ########### start of HTML code ########### print (""" <p>Thank you for your visit. Please come again. <p> </body></html> """) ############# end of HTML code ############## [/code] HTML Code: [code]<html> <head> </head> <body> <form action="practice9.py" method="post"> <input type="radio" name="drink" value="tea" checked > Tea <br> <input type="radio" name="drink" value="coffee" > Coffee <br> <input type="radio" name="drink" value="hot chocolate" > Hot Chocolate <p> <input type="submit" value="Place order"> </form> </body> </html>[/code] -- http://mail.python.org/mailman/listinfo/python-list