0

I am currently working on a program in python which keeps trak of a lot of builds. This progress is reported in a html file which is current deleted and written again with the new data for me to update it. However I know this is not the idea approach though i have never really worked with html web pages in any degree what so ever.

But i would like to make it the right way but every time i search on something i just get how to pass data from a html page into a program. So what i am asking for is some guide lines as to what I need to look for to achive this.

Also any suggestion as to how the right approach whould be. I just need to pass data from my running python program to a html page.

Ad if im lucky maybe someone posseses a very simple exsample. like just a python constant passed to a text box or what ever on a html page.

Regards Ephreal

Ephreal
  • 1,835
  • 2
  • 18
  • 35
  • why don't you try parsing to an xml file in your python program, and then bind the html to the xml? Just a suggestion, but xml files are quite handy like that as most languages have quite an extensive method group for that. Or you could simply write to a db and then read the db in your html? same idea really. [this](http://stackoverflow.com/a/1912516/3913686) might help –  Oct 08 '14 at 13:19

1 Answers1

0
#!/usr/bin/python3
__author__ = 'Aidan'
from urllib import request
goog_url = 'http://real-chart.finance.yahoo.com/table.csv?s=GOOG&d=8&e=2&f=2014&g=d&a=2&b=27&c=2014&ignore=.csv'


def dl(csv_url, dest):
    response = request.urlopen(csv_url)
    csv_str = str(response.read())
    lines = csv_str.split("\\n")
    fx = open(dest, "w")
    for line in lines:
        fx.write(line + "\n")
    fx.close()

dl(goog_url, 'a.csv')

This will take a file from the web band save it to a filename of your choice.

YoungCoder5
  • 845
  • 1
  • 7
  • 14