Last active
March 19, 2018 08:59
-
-
Save limemloh/5ac19fcba128f0c62ddbfdb7f6e6d92a to your computer and use it in GitHub Desktop.
This file contains 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
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