From ea7684c1b05d61c29c962c9bb3d941971be4e647 Mon Sep 17 00:00:00 2001 From: Harshit Mahajan Date: Wed, 3 Oct 2018 21:41:41 +0530 Subject: [PATCH] added files for automated code submission --- Codechef-Code-Submitter/README.md | 2 + .../automated-submission.py | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Codechef-Code-Submitter/README.md create mode 100644 Codechef-Code-Submitter/automated-submission.py diff --git a/Codechef-Code-Submitter/README.md b/Codechef-Code-Submitter/README.md new file mode 100644 index 0000000..6632307 --- /dev/null +++ b/Codechef-Code-Submitter/README.md @@ -0,0 +1,2 @@ +# Automated Submission +A simple script to submit you code on [https://www.codechef.com] using selenium. \ No newline at end of file diff --git a/Codechef-Code-Submitter/automated-submission.py b/Codechef-Code-Submitter/automated-submission.py new file mode 100644 index 0000000..ebc0549 --- /dev/null +++ b/Codechef-Code-Submitter/automated-submission.py @@ -0,0 +1,42 @@ +from selenium import webdriver +import getpass +import time + +username = "username" +password = getpass.getpass("Password:") + +problem = 'TEST' + +code = """ +#include + +int main(void) { +char c, d=10; +while(std::cin.get(c) && (c!='2' || d!='4') && std::cout.put(d)) +d=c; +} +""" + +browser = webdriver.Firefox() + +browser.get('https://www.codechef.com') + +nameElem = browser.find_element_by_id('edit-name') +nameElem.send_keys(username) + +passElem = browser.find_element_by_id('edit-pass') +passElem.send_keys(password) + +browser.find_element_by_id('edit-submit').click() + +browser.get("https://www.codechef.com/submit/" + problem) + +time.sleep(20) + +browser.find_element_by_id("edit_area_toggle_checkbox_edit-program").click() + +inputElem = browser.find_element_by_id('edit-program') +inputElem.send_keys(code) + +browser.find_element_by_id("edit-submit").click() +