Skip to content

Instantly share code, notes, and snippets.

@lacucaracha-jp
Created June 10, 2019 14:09
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 lacucaracha-jp/40e34f146e79d89b11295a2d425af3b4 to your computer and use it in GitHub Desktop.
Save lacucaracha-jp/40e34f146e79d89b11295a2d425af3b4 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
let page;
async function getBrowserPage() {
// Launch headless Chrome. Turn off sandbox so Chrome can run under root.
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
return browser.newPage();
}
exports.updateMoneyForward = async (req, res) => {
const url = "https://moneyforward.com/users/sign_in";
const mail = "メールアドレス";
const pw = "パスワード";
if (!page) {
page = await getBrowserPage();
}
await page.goto(url);
if((await page.title()) == 'ログイン|マネーフォワード ME'){
await page.focus('input[name="sign_in_session_service[email]"]');
await page.type('input[name="sign_in_session_service[email]"]',mail);
await page.focus('input[name="sign_in_session_service[password]"]');
await page.type('input[name="sign_in_session_service[password]"]',pw);
await page.click('#login-btn-sumit');
await page.waitFor(1000);
}
 await page.click('a[href="/aggregation_queue"]');
res.send('update終了');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment