How to log in to AtCoder with Python and submit automatically

Introduction

What do you use to submit to AtCoder? I think the majority of people on the AtCoder site say that, but I think there are also people who use atcoder-cli and online-judge-tools. I wanted to be able to submit it automatically by referring to [this site (and related articles)] 1, but it didn't work, so I wrote this article.

What I couldn't do

First of all, as shown in [Site] 1, even if I try to implement it, I cannot submit it successfully. Why. I spent about 3 days investigating the cause of this. That's stupid! !! However, if you are reading this article, I don't think you will play my second dance! !!

Cause investigation

First of all, I suspected that I couldn't log in. So I tried to reproduce the environment where I could not log in with a web browser.

For example, in [AtCoder Login] 2, try to make a mistake in the account name and password. Then, after all, you will be notified that you could not log in and you will stay on the same site, right? So, first of all, I doubted the redirect destination.

Also, I found it interesting when I was playing around with it, so I would like to introduce my [another article] 3.

After the post process of [Site] 0

print(result.url)

Write this and use .url to find the redirect destination. Then I

https://atcoder.jp:443/home

It was displayed like this. So if I changed the login url to this, I was able to log in and submit it normally. Please give it a try. If you are worried, you can write it with try ~ except statement without changing login_url and using the method of checking if you can log in [My article] 3.

end

Thank you for reading. The article has become quite confusing, but I hope you find it helpful. If you have any suggestions, I would appreciate it if you could comment. Thank you very much.

Recommended Posts

How to log in to AtCoder with Python and submit automatically
How to use is and == in Python
[REAPER] How to play with Reascript in Python
How to generate permutations in Python and C ++
Log in to Yahoo Business with Selenium Python
How to use tkinter with python in pyenv
How to plot autocorrelation and partial autocorrelation in python
How to get the date and time difference in seconds with python
How to automatically execute python script (with GUI) and sudo permission command after logging in with Ubuntu 18.04
How to develop in Python
How to convert / restore a string with [] in python
How to do hash calculation with salt in Python
Explain in detail how to make sounds with python
[Python] How to sort dict in list and instance in list
[Python] How to do PCA in Python
Python: How to use async with
How to collect images in Python
How to extract any appointment in Google Calendar with Python
[Python] How to play with class variables with decorator and metaclass
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
How to log in automatically like 1Password from the CLI
How to get started with Python
How to do Bulk Update with PyMySQL and notes [Python]
[Note] How to write QR code and description in the same image with python
Comparison of how to use higher-order functions in Python 2 and 3
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use FTP with Python
How to use PubChem in Python
Things to keep in mind when using Python with AtCoder
How to execute external shell scripts and commands in python
How to create dataframes and mess with elements in pandas
How to handle Japanese in Python
How to log in to Docker + NGINX
How to deal with python installation error in pyenv (BUILD FAILED)
How to install OpenCV on Cloud9 and run it in Python
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
How to import CSV and TSV files into SQLite with Python
How to use functions in separate files Perl and Python versions
How to make a surveillance camera (Security Camera) with Opencv and Python
How to use python put in pyenv on macOS with PyCall
How to deal with errors when installing Python and pip with choco
Try to log in to Netflix automatically using python on your PC
[ROS2] How to describe remap and parameter in python format launch
Throw something to Kinesis with python and make sure it's in
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
How to use Python with Jw_cad (Part 2 Command explanation and operation)
I tried to log in to twitter automatically with selenium (RPA, scraping)
How to display legend marks in one with Python 2D plot
How to build Python and Jupyter execution environment with VS Code
How to calculate "xx time" in one shot with Python timedelta
How to display bytes in the same way in Java and Python
[Introduction to Python] How to use class in Python?
Try logging in to qiita with Python
How to access environment variables in Python
How to dynamically define variables in Python
How to install and use pandas_datareader [Python]
How to do R chartr () in Python
[Itertools.permutations] How to put permutations in Python
Output Python log to console with GAE