import urllib2
import os
from bottle import get, post, request, run, Bottle
application = app = Bottle()
def get_result(exam, year, board, roll):
base_url = "http://www.educationboardresults.gov.bd/regular" #switch to archive.educationboard.gov.bd if this fails
index_response = urllib2.urlopen(base_url + "/index.php")
session_var = index_response.info().headers[3].split()[1][0:36] #getting PHPSESSID session cookie
post_data = "sr=3&et=0&exam=%s&year=%s&board=%s&roll=%s&button2=Submit" % (exam, year, board, roll)
result_request = urllib2.Request(base_url + "/result.php", headers = {'Cookie': session_var})
result_response = urllib2.urlopen(result_request, post_data)
return result_response.read()
@app.route('/')
def index_page():
# just the info entry page, don't validate HTML, please!
return '''Board Result Fetcher
'''
else: return result
if __name__ == '__main__':
run(app, host='0.0.0.0', port=80)
0 Comments