Hi all, I'm new to this list (and python ;-)) and working on a small personal project.
I'm basically using the twill to browse a website (weather reports) and do a re search for a specific string that once found, needs to be printed in a web page on it's own. The problem I found with twill is that it also prints the html that comes along with it. (Apparently it's a known "functionality") The way around this was for me to write my regexp find to another file and then display that in another cgi script, surely there must be a cleaner way of doing it? Also, any idea how I can call the second script from the first after the first one is finished? Any ideas appreciated. Code below.( No laughing please!) Cheers Heinrich import cgitb; cgitb.enable() # only for temp debugging import re import cgi from twill.commands import * url = "http://secure.metoffice.com/logon.jsp" go(url) fv(1, 'username', 'xxxxxxxx') fv(1, 'password', 'xxxxxxxx') submit() go('/aviation/index.jsp') go('report.jsp') go('reports.do?type=METAR&list=02') report = show() result = re.search("EGKB.*</td>",report) result = re.sub("</td>", "", result.group()) file = open('/var/www/cgi-bin/results.txt', 'w') print >>file, result file.flush() And then my second script runs this to display the one liner: import cgi import cgitb; cgitb.enable() # again only for temp debugging. def dispmetar(): f = open('results.txt', 'r') data = f.readlines() print 'Content-Type: text/html' print for line in data: print "<u>METAR</u>: " + line dispmetar() Just playing around with creating my own functions as you can tell... ---------------------------------------------- This mail sent through http://www.ukonline.net _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
