Skip to content

Commit

Permalink
Merge pull request #25 from Nullifiers/fixLoginIssue
Browse files Browse the repository at this point in the history
Fix login success check
  • Loading branch information
rishabhsingh971 authored Aug 7, 2019
2 parents f2efc69 + d4bd6f1 commit 1a7225d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hsc/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@ 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_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):
if not self.total_submissions:
all_submissions_url = self.get_all_submissions_url(0, 0)
resp = self.session.get(all_submissions_url, headers=self.headers)
self.total_submissions = resp.json()['total']
return self.total_submissions

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

Expand Down

0 comments on commit 1a7225d

Please sign in to comment.