@@ -65,9 +65,9 @@ def __init__(self):
65
65
self ._session = requests .Session ()
66
66
67
67
def check_logging_in (self ):
68
- private_url = "https://arc001.contest. atcoder.jp/settings "
68
+ private_url = "https://atcoder.jp/home "
69
69
resp = self ._request (private_url )
70
- return resp .url == private_url
70
+ return resp .text . find ( "Sign In" ) == - 1
71
71
72
72
def login (self ,
73
73
credential_supplier = None ,
@@ -89,9 +89,14 @@ def login(self,
89
89
90
90
username , password = credential_supplier ()
91
91
92
- resp = self ._request ("https://arc001.contest.atcoder.jp/login" , data = {
93
- 'name' : username ,
94
- "password" : password
92
+ soup = BeautifulSoup (self ._session .get (
93
+ "https://atcoder.jp/login" ).text , "html.parser" )
94
+ token = soup .find_all ("form" )[1 ].find (
95
+ "input" , type = "hidden" ).get ("value" )
96
+ resp = self ._request ("https://atcoder.jp/login" , data = {
97
+ 'username' : username ,
98
+ "password" : password ,
99
+ "csrf_token" : token
95
100
}, method = 'POST' )
96
101
97
102
if resp .text .find ("パスワードを忘れた方はこちら" ) != - 1 :
@@ -104,7 +109,8 @@ def download_problem_list(self, contest: Contest) -> List[Problem]:
104
109
resp = self ._request (contest .get_problem_list_url ())
105
110
soup = BeautifulSoup (resp .text , "html.parser" )
106
111
res = []
107
- for tag in soup .select ('.linkwrapper' )[0 ::2 ]:
112
+ for tag in soup .find ('table' ).select ('tr' )[1 ::]:
113
+ tag = tag .find ("a" )
108
114
alphabet = tag .text
109
115
problem_id = tag .get ("href" ).split ("/" )[- 1 ]
110
116
res .append (Problem (contest , alphabet , problem_id ))
@@ -158,25 +164,24 @@ def submit_source_code(self, contest: Contest, problem: Problem, lang: Union[str
158
164
soup = BeautifulSoup (resp .text , "html.parser" )
159
165
session_id = soup .find ("input" , attrs = {"type" : "hidden" }).get ("value" )
160
166
task_select_area = soup .find (
161
- 'select' , attrs = {"id" : "submit-task-selector" })
162
- task_field_name = task_select_area .get ("name" )
167
+ 'select' , attrs = {"id" : "select-task" })
163
168
task_number = task_select_area .find (
164
169
"option" , text = re .compile ('{} -' .format (problem .get_alphabet ()))).get ("value" )
165
170
language_select_area = soup .find (
166
- 'select' , attrs = {"id" : "submit-language-selector-{}" .format (task_number )})
167
- language_field_name = language_select_area .get ("name" )
171
+ 'select' , attrs = {"data-placeholder" : "-" })
168
172
language_number = language_select_area .find (
169
173
"option" , text = lang_option_pattern ).get ("value" )
170
174
postdata = {
171
- "__session " : session_id ,
172
- task_field_name : task_number ,
173
- language_field_name : language_number ,
174
- "source_code " : source
175
+ "csrf_token " : session_id ,
176
+ "data.TaskScreenName" : task_number ,
177
+ "data.LanguageId" : language_number ,
178
+ "sourceCode " : source
175
179
}
176
180
resp = self ._request (
177
181
contest .get_submit_url (),
178
182
data = postdata ,
179
183
method = 'POST' )
184
+
180
185
return Submission .make_submissions_from (resp .text )[0 ]
181
186
182
187
def download_submission_list (self , contest : Contest ) -> List [Submission ]:
0 commit comments