How do I programmatically submit an answer?

Announcements, comments, ideas, feedback, and "How do I... ?" questions
Post Reply
neighthann
Posts: 9
Joined: Thu Apr 09, 2020 5:15 pm

How do I programmatically submit an answer?

Post by neighthann »

I'm building an app interface to Project Euler, and it would be really nice if I could submit answers to problems through the app. However, I don't have much experience with HTTP requests. I've used the Chrome developer tools to extract the request made when I submit an answer on the website and copied that as a curl command, but there's some error when I try to run that from a terminal.

Is this possible? If it's possible, how would one go about doing this? I can see that the submit_token in the data changes between each submission, so my guess would be that I need to have proper value for that for my requests to go through? (PHPSESSID in the cookie header (and keep_alive) also change, but maybe only between visits to the site? It doesn't seem to be every submission).

neighthann
Posts: 9
Joined: Thu Apr 09, 2020 5:15 pm

Re: How do I programmatically submit an answer?

Post by neighthann »

Digging around on the problem page, I see that the submit token is given as part of the page. Since this comes from the server, I assume that means there's no nice way to send a POST request to check an answer, even if we have access to the username / password / cookie of the user? Though it should still be possible by navigating to the website itself, signing in for the user, then going to the problem page to get the submission token. This isn't as convenient but seems possible; I'll post here if I make any headway.

neighthann
Posts: 9
Joined: Thu Apr 09, 2020 5:15 pm

Re: How do I programmatically submit an answer?

Post by neighthann »

Oh, and there are sometimes captchas...

neighthann
Posts: 9
Joined: Thu Apr 09, 2020 5:15 pm

Re: How do I programmatically submit an answer?

Post by neighthann »

Aha, it works if you just copy the request from Chrome (e.g. as curl) then substitute in the submit_token that you get when you visit the page again, assuming you don't need to defeat a captcha and that the cookie header is the same.

Post Reply