Created
March 3, 2019 16:31
-
-
Save nikhilkumarsingh/b17f8d00bf58514e5874a8b5d9f0d192 to your computer and use it in GitHub Desktop.
GeeksforGeeks free, unrestricted online compiler api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
gfg_compiler_api_endpoint = "https://ide.geeksforgeeks.org/main.php" | |
languages = ['C', 'Cpp', 'Cpp14', 'Java', 'Python', 'Python3', 'Scala', 'Php', 'Perl', 'Csharp'] | |
def gfg_compile(lang, code, _input=None, save=False): | |
data = { | |
'lang': lang, | |
'code': code, | |
'input': _input, | |
'save': save | |
} | |
r = requests.post(gfg_compiler_api_endpoint, data=data) | |
return r.json() | |
if __name__ == "__main__": | |
lang = 'Cpp14' | |
code = """ | |
#include <iostream> | |
using namespace std; | |
int main() { | |
int a, b; | |
cin >> a >> b; | |
cout << (a+b); | |
return 0; | |
} | |
""" | |
_input = "1 5" | |
print(gfg_compile(lang, code, _input)) | |
This is sort of scraping and it is not an official api and I think it is not good of you have large base of users who want to submit code through this api
I guess this method does not work any more
Thank you for sharing this great API. I really want to suck your ... never mind :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to get output of execution?