Skip to content

Instantly share code, notes, and snippets.

@limemloh
Last active March 19, 2018 08:59
Show Gist options
  • Save limemloh/5ac19fcba128f0c62ddbfdb7f6e6d92a to your computer and use it in GitHub Desktop.
Save limemloh/5ac19fcba128f0c62ddbfdb7f6e6d92a to your computer and use it in GitHub Desktop.
const request = require("request-promise")
const cheerio = require("cheerio");
async function login(username, password) {
console.log("Loggin in...")
const body = await request("https://ungdomsboligaarhus.dk/user");
const $ = cheerio.load(body);
const form_build_id = $(`input[name="form_build_id"]`).val();
const formData = {
form_build_id,
form_id: "user_login",
name: username,
op: "Log+ind",
pass: password
}
const res = await request.post({ url: "https://ungdomsboligaarhus.dk/user", formData, resolveWithFullResponse: true, simple: false });
console.log("Response", res.statusCode, res.statusMessage)
}
login("<username>", "<password>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment