Skip to main content

My first Python script

Today i have wrote a python script to fetch the results of
all the students of my class and generate a html file to view the
results.

I have already posted a ruby script which is do the same thing. but
that was not written by me. It was done by Mr. rajkumar. He uses ruby to do that.

I have recently tried to implement my python knowledge so i have write a script
to do the same thing.

I assume that you already know how to run this script

 
#author: manimaran g
#use: script to fetch all the results and give a html file

#!/usr/bin/python

import urllib

url = "http://www.schools9.com/university-of-madras-exam-results0707.aspx?htno="
#this list will store the exam numbers
ex_no=[]
for num in range(495,505):
  ex_no.append('s900'+str(num))
#urlname list used to store the url+exam_number
urlname=[]
for i in range(len(ex_no)):
  urlname.append(url+ex_no[i])

for url in urlname:
  #reading each url in the urlname and read it and store in text
  text=urllib.urlopen(url).read()
  #open results.html file and append the result text
  file=open('results.html','a')
  file.write(text)
  file.close()

programming is fun :)

Comments