@@ -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,12 @@ 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 ("https://atcoder.jp/login" ).text , "html.parser" )
93
+ token = soup .find_all ("form" )[1 ].find ("input" , type = "hidden" ).get ("value" )
94
+ resp = self ._request ("https://atcoder.jp/login" , data = {
95
+ 'username' : username ,
96
+ "password" : password ,
97
+ "csrf_token" : token
95
98
}, method = 'POST' )
96
99
97
100
if resp .text .find ("パスワードを忘れた方はこちら" ) != - 1 :
@@ -104,7 +107,8 @@ def download_problem_list(self, contest: Contest) -> List[Problem]:
104
107
resp = self ._request (contest .get_problem_list_url ())
105
108
soup = BeautifulSoup (resp .text , "html.parser" )
106
109
res = []
107
- for tag in soup .select ('.linkwrapper' )[0 ::2 ]:
110
+ for tag in soup .find ('table' ).select ('tr' )[1 ::]:
111
+ tag = tag .find ("a" )
108
112
alphabet = tag .text
109
113
problem_id = tag .get ("href" ).split ("/" )[- 1 ]
110
114
res .append (Problem (contest , alphabet , problem_id ))
@@ -158,25 +162,26 @@ def submit_source_code(self, contest: Contest, problem: Problem, lang: Union[str
158
162
soup = BeautifulSoup (resp .text , "html.parser" )
159
163
session_id = soup .find ("input" , attrs = {"type" : "hidden" }).get ("value" )
160
164
task_select_area = soup .find (
161
- 'select' , attrs = {"id" : "submit -task-selector " })
165
+ 'select' , attrs = {"id" : "select -task" })
162
166
task_field_name = task_select_area .get ("name" )
163
167
task_number = task_select_area .find (
164
168
"option" , text = re .compile ('{} -' .format (problem .get_alphabet ()))).get ("value" )
165
169
language_select_area = soup .find (
166
- 'select' , attrs = {"id " : "submit-language-selector-{}" . format ( task_number ) })
170
+ 'select' , attrs = {"data-placeholder " : "-" })
167
171
language_field_name = language_select_area .get ("name" )
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