Python request returning IN-QUEUE status after posting

Viewed 98

I've been trying to learn and understand how http requests are being made between the clients and server, so I've decided to test out by sending a simple post request to geeksforgeeks' online IDE. Using requests, I am able to get a response of the following, {'status': 'SUCCESS', 'sid': 'df1acaffefacb25dfef2c7cf66022925'} using the following code,

import requests
import time
url = "https://ide.geeksforgeeks.org/main.php"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0'}

code = """
print("hello")
"""

data = {
    'lang':'Python3',
    'code': code,
    'input':'0',
    'save':'false'
}

r = requests.post(url, data = data, headers = headers)
print(r.json())

Next, I know that i have to resend back the sid parameter to https://ide.geeksforgeeks.org/submissionResult.php in order to get a successful response. However, when i entered the following code,

requesttype = {
    'sid': r.json()['sid'] ,
    'requestType': 'fetchResults'
}

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0'}

url2 = "https://ide.geeksforgeeks.org/submissionResult.php"

session = requests.Session()
outcome = session.post(url2, data = requesttype, headers = headers)

It returns {'status': 'IN-QUEUE'}. Upon analyzing the networks tab in my browser, it seems as though the online IDE has a queue system that will only parse your incoming request server sided through a queue-like system. Hence I would like to know how to obtain a success response by "communicating" with their queue system.

A successful response looks like this,


{"valid":"1","output":"testing\n","time":"0.02","compResult":"S","memory":"0.125","hash":"79c7a40c6f6b36f1dfc23119f27ba66e_Tester_U16","status":"SUCCESS"}

My hunch is telling me that the website is detecting me as a bot and I should use something else like selenium perhaps.

1 Answers

When I run the code on my computer, it works just fine. I believe the problem could be something to do with the SSL certificate that you might want to initialize.

Related