Skip to content

Commit 6bdc8ad

Browse files
committed
Changed the procedure to take student id and password from the console.
1 parent f1600ba commit 6bdc8ad

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

registrationToGoogle.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from oauth2client import client
77
from oauth2client import tools
88
from oauth2client import file
9+
from remote import registrationRepository
910

1011
import os, httplib2
1112
from datetime import datetime, timedelta
@@ -81,7 +82,6 @@ def get_credentials():
8182
print('Storing credentials to ' + credential_path)
8283
return credentials
8384

84-
8585
def createCalendar(service):
8686
"""
8787
Creates a calendar on Google Calendar.
@@ -96,8 +96,6 @@ def createCalendar(service):
9696
calendarId = creationResult.get("id")
9797
return calendarId
9898

99-
100-
10199
def fillCalendar(cId, service, rows):
102100

103101
for i in xrange(1, len(rows)):
@@ -127,12 +125,17 @@ def fillCalendar(cId, service, rows):
127125
}
128126
service.events().insert(calendarId=cId, body=eventDetails).execute()
129127
print "Entry processed : " + entry["name"]
130-
131128

132-
regFile = open("registrationPage.htm", "r")
133-
regPage = regFile.read()
129+
user_id = raw_input("Enter your student id : ")
130+
password = raw_input("Enter your password : ")
131+
132+
registration_repo = registrationRepository.RegistrationRepository(user_id, password)
133+
reg_page = registration_repo.get_reg_page()
134+
135+
#regFile = open("registrationPage.htm", "r")
136+
#regPage = regFile.read()
134137

135-
soup = BeautifulSoup(regPage, "html.parser")
138+
soup = BeautifulSoup(reg_page, "html.parser")
136139

137140
tables = soup.find_all("table")
138141

remote/registrationRepository.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ class RegistrationRepository:
88
COURSES_URL = "http://registration.boun.edu.tr/home.htm"
99
LOGIN_URL = "https://registration.boun.edu.tr/scripts/loginst.asp"
1010

11-
username = ""
11+
user_id = ""
1212
password = ""
1313
session = None
1414

15-
def __init__(self):
15+
def __init__(self, user_id, password):
1616
self.session = requests.session()
17+
self.user_id = user_id
18+
self.password = password
1719

1820
def get_reg_page(self):
19-
login_data = dict(user_id=self.username, user_pass=self.password)
21+
login_data = dict(user_id=self.user_id, user_pass=self.password)
2022
session_start_result = self.session.post(self.LOGIN_URL, data=login_data)
2123
return session_start_result.text
2224

0 commit comments

Comments
 (0)