/
output.py
executable file
·136 lines (100 loc) · 4.04 KB
/
output.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
'''
Output -> To print each sqlite table
Anna University Grader -> Extracts grades from anna univ site
NOTE: USE FRAMEWORK NEXT TIME. Hardcoded pages are n00b.
Feroze Naina
'''
from sqlite3 import *
from BeautifulSoup import BeautifulSoup
def htmlprint(branch):
f = open('temp.html', 'w')
#Hard insert CSS and Google Analytics
headers='''<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
<meta http-equiv="content-type" content="text/html">
<title>Feroze.in - AUG</title>
<style type="text/css" media="all">@import "style.css";</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21763445-1']);
_gaq.push(['_setDomainName', '.feroze.in']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head><body>
<div id="Header"><a href="http://feroze.in/aug/" title="AUG Home">Anna University Grader</a></div>
<div id="Content">
<h1> '''+branch+''' </h1>
<p>
<table>
<style type="text/css">
tr.heading { background-color: DarkOrange; }
</style>
<tr class="heading">
<td align=center>Regno</ td>
<td align=center>Name</ td>
<td align=center>English</ td>
<td align=center>Maths</ td>
<td align=center>Physics</ td>
<td align=center>Chem</ td>
<td align=center>EG</ td>
<td align=center>FOCP</ td>
<td align=center>CP Lab</ td>
<td align=center>EP Lab</ td>
<td align=center>GPA</ td></ tr>'''
f.write(headers)
conn = connect('marks.db')
curs = conn.cursor()
curs.execute("select * from "+branch)
for row in curs:
f.write('<tr>')
f.write('<td align=center>'+row[0]+'</ td>')
f.write('<td align=center>'+row[1]+'</ td>')
f.write('<td align=center>'+row[2]+'</ td>')
f.write('<td align=center>'+row[3]+'</ td>')
f.write('<td align=center>'+row[4]+'</ td>')
f.write('<td align=center>'+row[5]+'</ td>')
f.write('<td align=center>'+row[6]+'</ td>')
f.write('<td align=center>'+row[7]+'</ td>')
f.write('<td align=center>'+row[8]+'</ td>')
f.write('<td align=center>'+row[9]+'</ td>')
f.write('<td align=center>'+str(row[18])+'</ td>')
f.write('</ tr>')
f.write('''</ tr></ table></p>
</div>
<div id="Menu">
<a href="http://feroze.in/aug/index.html" title="Home">Home</a><br>
<a href="http://feroze.in/aug/overall.html" title="Overall">Overall Results + Statistics</a><br>
<a href="http://feroze.in/aug/EIE.html" title="EIE">EIE</a><br>
<a href="http://feroze.in/aug/ECE.html" title="EIE">ECE</a><br>
<a href="http://feroze.in/aug/EEE.html" title="EIE">EEE</a><br>
<a href="http://feroze.in/aug/CSE.html" title="EIE">CSE</a><br>
<a href="http://feroze.in/aug/IT.html" title="EIE">IT</a><br>
<a href="http://feroze.in/aug/Mech.html" title="EIE">Mech</a><br>
<a href="http://feroze.in/aug/Prod.html" title="EIE">Prod</a><br>
<a href="http://feroze.in/aug/faq.html" title="FAQ">Frequently Asked Questions</a><br>
<a href="http://feroze.in/aug/notes.html" title="">Notes</a><br>
<a href="http://feroze.in/" title="Feroze.in">Visit Feroze.in</a><br>
</body></html>''')
f.close()
i = open('temp.html', 'r')
input=i.read()
soup = BeautifulSoup(input)
output=soup.prettify()
o=open(branch+'.html', 'w')
o.write(output)
o.close()
i.close()
htmlprint('EIE')
htmlprint('EEE')
htmlprint('ECE')
htmlprint('Mech')
htmlprint('Prod')
htmlprint('Civil')
htmlprint('CSE')
htmlprint('IT')