Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix login success check #25

Merged
merged 2 commits into from
Aug 7, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion hsc/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ def login(self, username, password):
resp = self.session.get(self.login_url, auth=(username, password))
self.cookies = self.session.cookies.get_dict()
self.headers = resp.request.headers
return resp.url != self.login_url
self.get_number_of_submissions()
return self.total_number_of_submissions != 0

def authenticate(self):
username = input('Hackerrank Username: ')
password = getpass.getpass('Hackerrank Password: ')
return self.login(username, password)

def get_number_of_submissions(self):
rishabhsingh971 marked this conversation as resolved.
Show resolved Hide resolved
all_submissions_url = self.get_all_submissions_url(0, 0)
resp = self.session.get(all_submissions_url, headers=self.headers)
self.total_number_of_submissions = resp.json()['total']

def get_all_submissions_url(self, offset, limit):
return self.submissions_url.format(offset, limit)

Expand Down