{"action":"created","comment":{"url":"https://api.github.com/repos/metakgp/scripts/pulls/comments/80470043","id":80470043,"diff_hunk":"@@ -0,0 +1,122 @@\n+import requests\n+from bs4 import BeautifulSoup\n+\n+# For disabling the InsecurePlatForm warnings\n+import requests.packages.urllib3\n+requests.packages.urllib3.disable_warnings()\n+\n+import sys\n+\n+BASE_URL = 'https://erp.iitkgp.ernet.in/StudentPerformance/view_performance.jsp?rollno='\n+\n+\n+def get_cg(url):\n+    cgpa = ''\n+    try:\n+        r = requests.Session()\n+        response = r.get(url)\n+        response.raise_for_status()\n+    except requests.Timeout:\n+        print('error: timed out for', url[len(BASE_URL):])\n+        return 0\n+    except requests.ConnectionError:\n+        print('error: connection problem for', url[len(BASE_URL):])\n+        return 0\n+    except requests.HTTPError:\n+        print('error: invalid HTTP response for', url[len(BASE_URL):])\n+        return 0\n+    except requests.exceptions.ChunkedEncodingError as e:\n+        print('error: ChunkedEncodingError', url)\n+        return 0\n+    soup = BeautifulSoup(response.text.replace('&nbsp', ''), 'lxml')\n+    tds = soup.find_all('td')\n+    for idx, td in enumerate(tds):\n+        if td.text.strip() == 'CGPA':\n+            cgpa = tds[idx + 1].text\n+            return cgpa\n+\n+\n+def get_rank(cg_list, mycg):\n+    sorted_list = []\n+    rank = 1\n+    for stud in cg_list:\n+        cg = stud.values()[0]\n+        # check for existent cg\n+        if bool(cg) and float(cg) > float(mycg):\n+            rank += 1\n+    return rank\n+\n+\n+def check_roll_and_return_cg(rollno):\n+    mycg = ''\n+    url = BASE_URL + rollno\n+    # print url\n+    try:\n+        r = requests.Session()\n+        response = r.get(url)\n+        response.raise_for_status()\n+    except requests.Timeout:\n+        print('error: timed out', url)\n+        return 0\n+    except requests.ConnectionError:\n+        print('error: connection problem', url)\n+        return 0\n+    except requests.HTTPError:\n+        print('error: invalid HTTP response', url)\n+        return 0\n+    except requests.exceptions.ChunkedEncodingError as e:\n+        print('error: ChunkedEncodingError', url)\n+        return 0\n+\n+    soup = BeautifulSoup(response.text.replace('&nbsp', ''), 'lxml')\n+    tds = soup.find_all('td')\n+    for idx, td in enumerate(tds):\n+        if td.text.strip() == 'CGPA':\n+            mycg = tds[idx + 1].text\n+            return mycg\n+\n+if __name__ == '__main__':\n+    rollno = raw_input('Enter your roll number please : ')\n+    rollno = rollno.replace(' ', '').upper()\n+    print 'Okay wait for some time...let me check'\n+    mycg = check_roll_and_return_cg(rollno)\n+    if not mycg or mycg == '':\n+        print \"\"\"Hmm...it seems like there is some kind of an issue.\\n\n+                Please try again.\"\"\"\n+        sys.exit(0)\n+    cg_list = []\n+    # varialble to keep track of invalid roll numbers\n+    invalid_roll_count = 0\n+    # the final two digits of a roll number\n+    index = 1\n+\n+    # if no roll number found for 5 times continuously I'll assume the branch's student list has ended\n+    while invalid_roll_count < 6:\n+        cg_json = {}\n+\n+        # roll number genrated by the script\n+        dynamic_roll = rollno[:-2]\n+        if index < 10:\n+            dynamic_roll += '0' + str(index)\n+        else:\n+            dynamic_roll += str(index)\n+        # print dynamic_roll\n+        url = BASE_URL + dynamic_roll\n+        if dynamic_roll == rollno:\n+            pass\n+        # NOTE: check if it prints the user's url. It should not actually\n+        cgpa = get_cg(url)\n+        if not bool(cgpa):\n+            invalid_roll_count += 1\n+            print 'invalid_roll_count', invalid_roll_count\n+            index += 1","path":"get_branch_rank.py","position":null,"original_position":112,"commit_id":"e13c997b2feee5a4446cc8dfd447e4bfd500e22c","original_commit_id":"c95c1bba729e3b64124940487a5cf55f9ee5844f","user":{"login":"icyflame","id":3668034,"avatar_url":"https://avatars.githubusercontent.com/u/3668034?v=3","gravatar_id":"","url":"https://api.github.com/users/icyflame","html_url":"https://github.com/icyflame","followers_url":"https://api.github.com/users/icyflame/followers","following_url":"https://api.github.com/users/icyflame/following{/other_user}","gists_url":"https://api.github.com/users/icyflame/gists{/gist_id}","starred_url":"https://api.github.com/users/icyflame/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icyflame/subscriptions","organizations_url":"https://api.github.com/users/icyflame/orgs","repos_url":"https://api.github.com/users/icyflame/repos","events_url":"https://api.github.com/users/icyflame/events{/privacy}","received_events_url":"https://api.github.com/users/icyflame/received_events","type":"User","site_admin":false},"body":"@zorroblue @Demfier I have read the script, and it looks like the total number of people in the batch is being clearly mentioned by the script in the final output. So, if the script also mentions the number of roll numbers that were considered as `invalid` because the CGPA couldn't be retrieved, it would be a good enough solution. Correct me if any of my understanding is wrong.","created_at":"2016-09-26T13:07:24Z","updated_at":"2016-09-26T13:07:24Z","html_url":"https://github.com/metakgp/scripts/pull/4#discussion_r80470043","pull_request_url":"https://api.github.com/repos/metakgp/scripts/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/comments/80470043"},"html":{"href":"https://github.com/metakgp/scripts/pull/4#discussion_r80470043"},"pull_request":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/metakgp/scripts/pulls/4","id":86622931,"html_url":"https://github.com/metakgp/scripts/pull/4","diff_url":"https://github.com/metakgp/scripts/pull/4.diff","patch_url":"https://github.com/metakgp/scripts/pull/4.patch","issue_url":"https://api.github.com/repos/metakgp/scripts/issues/4","number":4,"state":"open","locked":false,"title":"added branch rank calculator for metakgp/scripts","user":{"login":"Demfier","id":12595718,"avatar_url":"https://avatars.githubusercontent.com/u/12595718?v=3","gravatar_id":"","url":"https://api.github.com/users/Demfier","html_url":"https://github.com/Demfier","followers_url":"https://api.github.com/users/Demfier/followers","following_url":"https://api.github.com/users/Demfier/following{/other_user}","gists_url":"https://api.github.com/users/Demfier/gists{/gist_id}","starred_url":"https://api.github.com/users/Demfier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Demfier/subscriptions","organizations_url":"https://api.github.com/users/Demfier/orgs","repos_url":"https://api.github.com/users/Demfier/repos","events_url":"https://api.github.com/users/Demfier/events{/privacy}","received_events_url":"https://api.github.com/users/Demfier/received_events","type":"User","site_admin":false},"body":"Instructions to use can be found on https://github.com/Demfier/Get-branch-rank/","created_at":"2016-09-24T16:33:01Z","updated_at":"2016-09-26T13:07:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c06e0bfd14a8d3ef6969685e848a69fae30f5da","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/metakgp/scripts/pulls/4/commits","review_comments_url":"https://api.github.com/repos/metakgp/scripts/pulls/4/comments","review_comment_url":"https://api.github.com/repos/metakgp/scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metakgp/scripts/issues/4/comments","statuses_url":"https://api.github.com/repos/metakgp/scripts/statuses/e13c997b2feee5a4446cc8dfd447e4bfd500e22c","head":{"label":"Demfier:master","ref":"master","sha":"e13c997b2feee5a4446cc8dfd447e4bfd500e22c","user":{"login":"Demfier","id":12595718,"avatar_url":"https://avatars.githubusercontent.com/u/12595718?v=3","gravatar_id":"","url":"https://api.github.com/users/Demfier","html_url":"https://github.com/Demfier","followers_url":"https://api.github.com/users/Demfier/followers","following_url":"https://api.github.com/users/Demfier/following{/other_user}","gists_url":"https://api.github.com/users/Demfier/gists{/gist_id}","starred_url":"https://api.github.com/users/Demfier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Demfier/subscriptions","organizations_url":"https://api.github.com/users/Demfier/orgs","repos_url":"https://api.github.com/users/Demfier/repos","events_url":"https://api.github.com/users/Demfier/events{/privacy}","received_events_url":"https://api.github.com/users/Demfier/received_events","type":"User","site_admin":false},"repo":{"id":69113718,"name":"scripts","full_name":"Demfier/scripts","owner":{"login":"Demfier","id":12595718,"avatar_url":"https://avatars.githubusercontent.com/u/12595718?v=3","gravatar_id":"","url":"https://api.github.com/users/Demfier","html_url":"https://github.com/Demfier","followers_url":"https://api.github.com/users/Demfier/followers","following_url":"https://api.github.com/users/Demfier/following{/other_user}","gists_url":"https://api.github.com/users/Demfier/gists{/gist_id}","starred_url":"https://api.github.com/users/Demfier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Demfier/subscriptions","organizations_url":"https://api.github.com/users/Demfier/orgs","repos_url":"https://api.github.com/users/Demfier/repos","events_url":"https://api.github.com/users/Demfier/events{/privacy}","received_events_url":"https://api.github.com/users/Demfier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Demfier/scripts","description":"Scripts used in generation and maintenance of metaKGP content","fork":true,"url":"https://api.github.com/repos/Demfier/scripts","forks_url":"https://api.github.com/repos/Demfier/scripts/forks","keys_url":"https://api.github.com/repos/Demfier/scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Demfier/scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Demfier/scripts/teams","hooks_url":"https://api.github.com/repos/Demfier/scripts/hooks","issue_events_url":"https://api.github.com/repos/Demfier/scripts/issues/events{/number}","events_url":"https://api.github.com/repos/Demfier/scripts/events","assignees_url":"https://api.github.com/repos/Demfier/scripts/assignees{/user}","branches_url":"https://api.github.com/repos/Demfier/scripts/branches{/branch}","tags_url":"https://api.github.com/repos/Demfier/scripts/tags","blobs_url":"https://api.github.com/repos/Demfier/scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Demfier/scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Demfier/scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/Demfier/scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Demfier/scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/Demfier/scripts/languages","stargazers_url":"https://api.github.com/repos/Demfier/scripts/stargazers","contributors_url":"https://api.github.com/repos/Demfier/scripts/contributors","subscribers_url":"https://api.github.com/repos/Demfier/scripts/subscribers","subscription_url":"https://api.github.com/repos/Demfier/scripts/subscription","commits_url":"https://api.github.com/repos/Demfier/scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/Demfier/scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/Demfier/scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/Demfier/scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/Demfier/scripts/contents/{+path}","compare_url":"https://api.github.com/repos/Demfier/scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Demfier/scripts/merges","archive_url":"https://api.github.com/repos/Demfier/scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Demfier/scripts/downloads","issues_url":"https://api.github.com/repos/Demfier/scripts/issues{/number}","pulls_url":"https://api.github.com/repos/Demfier/scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/Demfier/scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/Demfier/scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Demfier/scripts/labels{/name}","releases_url":"https://api.github.com/repos/Demfier/scripts/releases{/id}","deployments_url":"https://api.github.com/repos/Demfier/scripts/deployments","created_at":"2016-09-24T16:25:58Z","updated_at":"2016-09-24T16:25:59Z","pushed_at":"2016-09-24T23:59:30Z","git_url":"git://github.com/Demfier/scripts.git","ssh_url":"git@github.com:Demfier/scripts.git","clone_url":"https://github.com/Demfier/scripts.git","svn_url":"https://github.com/Demfier/scripts","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"metakgp:master","ref":"master","sha":"49f22cdf01cd360c2713d4e6fb4ca6dc2fa253f4","user":{"login":"metakgp","id":11089056,"avatar_url":"https://avatars.githubusercontent.com/u/11089056?v=3","gravatar_id":"","url":"https://api.github.com/users/metakgp","html_url":"https://github.com/metakgp","followers_url":"https://api.github.com/users/metakgp/followers","following_url":"https://api.github.com/users/metakgp/following{/other_user}","gists_url":"https://api.github.com/users/metakgp/gists{/gist_id}","starred_url":"https://api.github.com/users/metakgp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metakgp/subscriptions","organizations_url":"https://api.github.com/users/metakgp/orgs","repos_url":"https://api.github.com/users/metakgp/repos","events_url":"https://api.github.com/users/metakgp/events{/privacy}","received_events_url":"https://api.github.com/users/metakgp/received_events","type":"Organization","site_admin":false},"repo":{"id":40561153,"name":"scripts","full_name":"metakgp/scripts","owner":{"login":"metakgp","id":11089056,"avatar_url":"https://avatars.githubusercontent.com/u/11089056?v=3","gravatar_id":"","url":"https://api.github.com/users/metakgp","html_url":"https://github.com/metakgp","followers_url":"https://api.github.com/users/metakgp/followers","following_url":"https://api.github.com/users/metakgp/following{/other_user}","gists_url":"https://api.github.com/users/metakgp/gists{/gist_id}","starred_url":"https://api.github.com/users/metakgp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metakgp/subscriptions","organizations_url":"https://api.github.com/users/metakgp/orgs","repos_url":"https://api.github.com/users/metakgp/repos","events_url":"https://api.github.com/users/metakgp/events{/privacy}","received_events_url":"https://api.github.com/users/metakgp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metakgp/scripts","description":"Scripts used in generation and maintenance of metaKGP content","fork":false,"url":"https://api.github.com/repos/metakgp/scripts","forks_url":"https://api.github.com/repos/metakgp/scripts/forks","keys_url":"https://api.github.com/repos/metakgp/scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metakgp/scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metakgp/scripts/teams","hooks_url":"https://api.github.com/repos/metakgp/scripts/hooks","issue_events_url":"https://api.github.com/repos/metakgp/scripts/issues/events{/number}","events_url":"https://api.github.com/repos/metakgp/scripts/events","assignees_url":"https://api.github.com/repos/metakgp/scripts/assignees{/user}","branches_url":"https://api.github.com/repos/metakgp/scripts/branches{/branch}","tags_url":"https://api.github.com/repos/metakgp/scripts/tags","blobs_url":"https://api.github.com/repos/metakgp/scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metakgp/scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metakgp/scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/metakgp/scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metakgp/scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/metakgp/scripts/languages","stargazers_url":"https://api.github.com/repos/metakgp/scripts/stargazers","contributors_url":"https://api.github.com/repos/metakgp/scripts/contributors","subscribers_url":"https://api.github.com/repos/metakgp/scripts/subscribers","subscription_url":"https://api.github.com/repos/metakgp/scripts/subscription","commits_url":"https://api.github.com/repos/metakgp/scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/metakgp/scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/metakgp/scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/metakgp/scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/metakgp/scripts/contents/{+path}","compare_url":"https://api.github.com/repos/metakgp/scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metakgp/scripts/merges","archive_url":"https://api.github.com/repos/metakgp/scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metakgp/scripts/downloads","issues_url":"https://api.github.com/repos/metakgp/scripts/issues{/number}","pulls_url":"https://api.github.com/repos/metakgp/scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/metakgp/scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/metakgp/scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metakgp/scripts/labels{/name}","releases_url":"https://api.github.com/repos/metakgp/scripts/releases{/id}","deployments_url":"https://api.github.com/repos/metakgp/scripts/deployments","created_at":"2015-08-11T19:33:31Z","updated_at":"2016-02-25T19:02:09Z","pushed_at":"2016-09-24T23:59:30Z","git_url":"git://github.com/metakgp/scripts.git","ssh_url":"git@github.com:metakgp/scripts.git","clone_url":"https://github.com/metakgp/scripts.git","svn_url":"https://github.com/metakgp/scripts","homepage":null,"size":4,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/4"},"html":{"href":"https://github.com/metakgp/scripts/pull/4"},"issue":{"href":"https://api.github.com/repos/metakgp/scripts/issues/4"},"comments":{"href":"https://api.github.com/repos/metakgp/scripts/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metakgp/scripts/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/metakgp/scripts/statuses/e13c997b2feee5a4446cc8dfd447e4bfd500e22c"}}}}
{"actor":{"display_login":"icyflame"}}