Guest User

Getting input and output data

a guest
Apr 25th, 2022
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.chrome.options import Options
  4. import os
  5.  
  6. contest_id, problem_letter, test_case = input().split(' '); test_case = int(test_case)
  7.  
  8. option = webdriver.ChromeOptions()
  9. option.add_argument('headless')
  10.  
  11. PATH = r"C:\Users\Vito\Programs\chromedriver.exe"
  12. driver = webdriver.Chrome(PATH, options=option)
  13.  
  14. driver.get(f"https://www.codeforces.com/contest/{contest_id}/problem/{problem_letter}")
  15.  
  16. os.system("cmd /c cls")
  17.  
  18. problem = driver.find_element(by=By.CLASS_NAME, value="title")
  19.  
  20. print("\nCollected input and output data for problem:", problem.text, sep="\n")
  21.  
  22. input_file = open("input.txt", "w")
  23. correct_output_file = open("correct_output.txt", "w")
  24.  
  25. io = driver.find_elements(by=By.TAG_NAME, value="pre")
  26.  
  27. input_file.write(io[test_case*2-2].text+"\n")
  28. correct_output_file.write(io[test_case*2-1].text+"\n")
  29. input_file.close()
  30. correct_output_file.close()
  31.  
  32. driver.quit()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment