dimanche 19 avril 2015

How can I connect my python script with my HTML file?

Basically I am getting some data from a webpage, and putting it into an array, I want to output the contents of that array into a table in a HTML file. After some research I found that using a mako template might be the best solution, but I don't understand how to use it? Can any one guide me through the steps or offer a better solution to execute this python script and output its result on the web?



import urllib2
import mako
from bs4 import BeautifulSoup as BS

html = urllib2.urlopen("<link-to-web-page>")
soup = BS(html)
data = []


for each_course in soup.findAll('li',{'class':'<class-name>'}):
inner_text = each_course.text
data.append(inner_text)


for i in data:
print (i+"\n")

Aucun commentaire:

Enregistrer un commentaire