-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompiler.js
More file actions
39 lines (30 loc) · 875 Bytes
/
compiler.js
File metadata and controls
39 lines (30 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const fetch = require("node-fetch");
var c = `
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
cout<<"Hello World"<<endl;
}`;
let sid;
fetch("https://ide.geeksforgeeks.org/main.php", {
headers: {
"accept": "application/json, text/javascript, */*; q=0.01",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"method": 'POST',
"body": "lang=Cpp14&code="+c+"&input=&save=false"
}).then(response => {return response.json()}).then(data => {
const json = JSON.stringify(data);
const val = JSON.parse(json);
data_function(val.sid);
});
function data_function(data){
sid = data;
console.log(sid);
}