An API to submit code to CodeForces using Selenium and Spring Boot.
public class test {
static String code = "YOUR CODE HERE";
public static void main(String[] args) {
WebClient client = WebClient.create("http://localhost:8080");
SubmissionInfo problemData = new SubmissionInfo();
problemData.solutionCode = code; // code
problemData.compilerId = 54; // compiler
ProblemSubmitRes res = client.post()
.uri("submit/{PROBLEM CODE}") // add your problem code
.body(BodyInserters.fromValue(problemData))
.retrieve()
.bodyToMono(ProblemSubmitRes.class)
.block();
System.out.println(res);
}
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class ProblemSubmitRes {
String verdict;
String time;
String memory;
String submitTime;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class SubmissionInfo {
String solutionCode;
Integer compilerId;
}
Add webclient dependency
Add lombok dependency
- localhost:8080/submit/{problemCode} - POST
Example:
submit/4A
{
"code" : "test code 11" ,
"programTypeId" : 54
}