From 61056303d22039ac573f459b634dbf1d03c89233 Mon Sep 17 00:00:00 2001 From: Abhijeet Reddy Date: Sun, 17 Oct 2021 13:19:28 +0530 Subject: [PATCH 1/3] fixed issue #23 --- details_soup.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/details_soup.py b/details_soup.py index a09ad02..0ebc175 100644 --- a/details_soup.py +++ b/details_soup.py @@ -146,18 +146,24 @@ def problems_solved_get(): return fully_solved, partially_solved def user_details_get(): + user_details_attribute_exclusion_list = {'username', 'link', 'teams list', 'discuss profile'} + header_containers = soup.find_all('header') name = header_containers[1].find('h1', class_="h2-style").text user_details_section = soup.find('section', class_='user-details') user_details_list = user_details_section.find_all('li') - return {'name': name, 'username': user_details_list[0].text.split('★')[-1].rstrip('\n'), - 'country': user_details_list[1].text.split(':')[-1].strip(), - 'state': user_details_list[2].text.split(':')[-1].strip(), - 'city': user_details_list[3].text.split(':')[-1].strip(), - 'student/professional': user_details_list[4].text.split(':')[-1].strip(), - 'institution': user_details_list[5].text.split(':')[-1].strip()} + user_details_response = {'name': name, 'username': user_details_list[0].text.split('★')[-1].rstrip('\n')} + for user_details in user_details_list: + attribute, value = user_details.text.split(':')[:2] + attribute = attribute.strip().lower() + value = value.strip() + + if attribute not in user_details_attribute_exclusion_list: + user_details_response[attribute] = value + + return user_details_response full, partial = problems_solved_get() details = {'status': 'Success', 'rating': int(rating), 'stars': stars, 'highest_rating': int(highest_rating), From 051952997f8e399840b2a738700d589d228694ad Mon Sep 17 00:00:00 2001 From: Yash Eksambekar <49578836+samba9274@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:51:51 +0530 Subject: [PATCH 2/3] Adapted to new codechef page layout (#31) --- details_soup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/details_soup.py b/details_soup.py index 0ebc175..f257b3f 100644 --- a/details_soup.py +++ b/details_soup.py @@ -56,13 +56,14 @@ def __codechef(self): global_rank = rating_ranks[0].strong.text country_rank = rating_ranks[1].strong.text - if global_rank != 'NA': + if global_rank != 'NA' and global_rank != 'Inactive': global_rank = int(global_rank) country_rank = int(country_rank) def contests_details_get(): rating_table = soup.find('table', class_='rating-table') - + if not rating_table: + return [] rating_table_rows = rating_table.find_all('td') '''Can add ranking url to contests''' From ac0a3c0cfbf1715e02f1638f9732eb895e1299ea Mon Sep 17 00:00:00 2001 From: Abhijeet Reddy Date: Mon, 6 Jun 2022 19:10:54 +0530 Subject: [PATCH 3/3] upgrade requests, urllib dependencies --- requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c44676a..74267db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,9 +13,10 @@ itsdangerous==1.1.0 Jinja2==2.11.3 MarkupSafe==1.1.1 pytz==2019.3 -requests==2.22.0 +requests==2.27.1 +selenium==3.141.0 six==1.14.0 soupsieve==1.9.5 -urllib3==1.26.5 +urllib3==1.26.9 Werkzeug==0.16.1 selenium==3.141.0 \ No newline at end of file