Skip to content

Instantly share code, notes, and snippets.

@Hyllesen
Created April 13, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hyllesen/b58a9b98107bdf16201ae827ccde1b04 to your computer and use it in GitHub Desktop.
Save Hyllesen/b58a9b98107bdf16201ae827ccde1b04 to your computer and use it in GitHub Desktop.
let request = require("request-promise");
const cookieJar = request.jar();
const fs = require("fs");
request = request.defaults({
jar: cookieJar,
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36",
},
});
async function main() {
const result = await request.get("https://internshala.com/");
const cookieString = cookieJar.getCookieString("https://internshala.com/");
const splitByName = cookieString.split("csrf_cookie_name=");
const splitBySemiColon = splitByName[1].split(";");
const csrf_test_name = splitBySemiColon[0];
const postResult = await request.post(
"https://internshala.com/login/verify_ajax/user",
{
form: {
csrf_test_name,
email: "************",
password: "***********",
},
}
);
fs.writeFileSync("./loggedin.html", postResult);
const matches = await request.get(
"https://internshala.com/internships/matching-preferences"
);
fs.writeFileSync("./matches.html", matches);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment