@@ -127,7 +127,10 @@ def problems(self, show_solved=True, show_partial=True, show_tried=False, show_u
127127 response = f .result ()
128128 soup = bs (response .content , features = 'lxml' )
129129 if not soup : continue
130- table = soup .find ('section' , class_ = 'strip strip-item-plain' ).find ('table' , class_ = 'table2' )
130+ try :
131+ table = soup .find ('section' , class_ = 'strip strip-item-plain' ).find ('table' , class_ = 'table2' )
132+ except AttributeError :
133+ continue # end of page (no data found)
131134 try :
132135 table_content = table .tbody .find_all ('tr' )
133136 except AttributeError :
@@ -212,10 +215,19 @@ def problems_v2(self, show_non_ac=False):
212215 columns = row .find_all ('td' )
213216 if columns and len (columns ) > 2 :
214217 has_content = True
215- pid = columns [2 ].find_all ('a' )[- 1 ].get ('href' ).split ('/' )[- 1 ] # might have two links if it belongs to a contest
218+ # column 0: plagiarism
219+ # column 1: time of submission
220+ # column 2: group/team
221+ # column 3: {problem_name} or {contest_name}/{problem_name}
222+ # column 4: status
223+ # column 5: runtime
224+ # column 6: language
225+ # column 7: testcases
226+ # column 8: button to view details
227+ pid = columns [3 ].find_all ('a' )[- 1 ].get ('href' ).split ('/' )[- 1 ].strip () # might have two links if it belongs to a contest
216228 if pid not in pid_set :
217229 link = f"{ self .BASE_URL } /problems/{ pid } "
218- name = columns [2 ].text .split ('/' )[- 1 ].strip ()
230+ name = columns [3 ].text .split ('/' )[- 1 ].strip ()
219231 pid_set .add (pid )
220232 data .append ({
221233 'name' : name ,
@@ -515,14 +527,23 @@ def stats(self, language='', *languages):
515527 columns = row .find_all ('td' )
516528 columns_text = [column .text .strip () for column in columns if column .text .strip ()]
517529 if columns_text :
530+ # column 0: plagiarism
531+ # column 1: time of submission
532+ # column 2: group/team
533+ # column 3: {problem_name} or {contest_name}/{problem_name}
534+ # column 4: status
535+ # column 5: runtime
536+ # column 6: language
537+ # column 7: testcases
538+ # column 8: button to view details
518539 has_content = True
519- link = f"{ self .BASE_URL } /submissions/{ columns [- 1 ].find ('a' ).get ('href' ).split ('/' )[- 1 ]} "
520- ts = columns_text [ 0 ]
521- pid = columns [2 ].find_all ('a' )[- 1 ].get ('href' ).split ('/' )[- 1 ] # use find_all as a workaround for contest links
522- name = columns_text [ 1 ]. split (' / ' )[- 1 ]
523- runtime = ' ' .join (columns_text [ 3 ] .split ()[:- 1 ]) # not converting to float because some TLE solutions (with '>') can also be AC
524- language = columns_text [ 4 ]
525- tc_pass , tc_full = map (int , columns_text [ 5 ] .split ('/' ))
540+ link = f"{ self .BASE_URL } /submissions/{ columns [8 ].find ('a' ).get ('href' ).split ('/' )[- 1 ]} "
541+ ts = columns [ 1 ]. text . strip ()
542+ pid = columns [3 ].find_all ('a' )[- 1 ].get ('href' ).split ('/' )[- 1 ]. strip () # might have two links if it belongs to a contest
543+ name = columns [ 3 ]. text . split (' / ' )[- 1 ]. strip ()
544+ runtime = ' ' .join (columns [ 5 ]. text .split ()[:- 1 ]) # not converting to float because some TLE solutions (with '>') can also be AC
545+ language = columns [ 6 ]. text . strip ()
546+ tc_pass , tc_full = map (int , columns [ 7 ]. text .split ('/' ))
526547 new_data = {
527548 'name' : name ,
528549 'timestamp' : ts ,
@@ -532,7 +553,7 @@ def stats(self, language='', *languages):
532553 'test_case_full' : tc_full ,
533554 'link' : link
534555 }
535- pts_regex = re .findall (r'[\d\.]+' , columns_text [ 2 ] )
556+ pts_regex = re .findall (r'[\d\.]+' , columns [ 4 ]. text )
536557 if pts_regex :
537558 new_data ['score' ] = float (pts_regex [0 ])
538559 if pid not in data :
@@ -601,7 +622,7 @@ def ranklist(self, top_100=False, country=None, university=None):
601622 columns_text = [column .text .strip () for column in columns ]
602623 columns_url = [column .find_all ('a' ) for column in columns ]
603624
604- rank = int (columns_text [0 ])
625+ rank = int (columns_text [0 ]) if columns_text [ 0 ]. isdigit () else None
605626 name = columns_text [1 ]
606627 pts = float (columns_text [- 1 ])
607628 name_urls = columns_url [1 ]
0 commit comments