Created
June 10, 2019 14:09
-
-
Save lacucaracha-jp/40e34f146e79d89b11295a2d425af3b4 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 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