@@ -63,18 +63,28 @@ def save_ac_code(ac_list, premium):
63
63
# Get submission details
64
64
testcase = soup .find ("span" , id = "result_progress" ).text
65
65
runtime = soup .find ("span" , id = "result_runtime" ).text
66
- ranking = soup .find ("div" , style = "line-height: 1em; position: relative;" )
67
- if ranking :
68
- ranking = ranking .text .replace ("\n " , " " ).replace (" " , "" )[15 :]
69
- else :
70
- ranking = "Your runtime beats 00.00 % of submissions."
66
+ memory = soup .find ("span" , id = "result_memory" ).text
67
+ ranking_list = soup .find_all ("div" , style = "line-height: 1em; position: relative;" )
68
+ if len (ranking_list ) == 2 :
69
+ ranking_runtime = ranking_list [0 ].text .replace ("\n " , " " ).replace (" " , "" )[15 :]
70
+ ranking_memory = ranking_list [1 ].text .replace ("\n " , " " ).replace (" " , "" )[15 :]
71
+ elif len (ranking_list ) == 1 :
72
+ ranking_runtime = ranking_list [0 ].text .replace ("\n " , " " ).replace (" " , "" )[15 :]
73
+ ranking_memory = "Your memory usage beats 00.00 % of submissions."
74
+ elif len (ranking_list ) == 0 :
75
+ ranking_runtime = "Your runtime beats 00.00 % of submissions."
76
+ ranking_memory = "Your memory usage beats 00.00 % of submissions."
77
+
71
78
submission_detail = ("/*\n " + "Submission Detail:{" +
72
- "\n Difficulty : " + difficulty +
73
- "\n Acceptance Rate : " + str (ac ["ac_rate" ]* 100 )[:5 ] + " %" +
74
- "\n Runtime : " + runtime +
75
- "\n Testcase : " + testcase + " passed" +
76
- "\n Ranking : " + ranking +
77
- "\n }\n */\n \n " )
79
+ "\n Difficulty : " + difficulty +
80
+ "\n Acceptance Rate : " + str (ac ["ac_rate" ]* 100 )[:5 ] + " %" +
81
+ "\n Runtime : " + runtime +
82
+ "\n Memory Usage : " + memory +
83
+ "\n Testcase : " + testcase + " passed" +
84
+ "\n Ranking : " +
85
+ "\n " + ranking_runtime +
86
+ "\n " + ranking_memory +
87
+ "\n }\n */\n \n " )
78
88
79
89
# Get ac code
80
90
script = soup .find ("script" , text = re .compile ("submissionCode:" ))
0 commit comments