Created
June 11, 2018 19:53
-
-
Save YusukeIwaki/b3f64a41fe4b8a2d2d65c0af40eaec89 to your computer and use it in GitHub Desktop.
puppeteer-page-walkerを使った、楽天銀行残高の確認コード
This file contains hidden or 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 userId = "??????????????"; | |
const loginPassword = "???????????"; | |
const branchCode = "???"; | |
const accountNumber = "???????"; | |
const secretWords = { | |
"卒業した中学校": "???????", | |
"母親の旧姓": "??????", | |
"??????": "??????" | |
}; | |
const PageWalker = require("puppeteer-page-walker"); | |
new PageWalker() | |
.initWith(async (page,self) => { | |
return await page.goto("https://www.rakuten-bank.co.jp/"); | |
}) | |
.andIf("https://www.rakuten-bank.co.jp/", async (page,self) => { | |
await page.click("a.login"); | |
}) | |
.andIf(url => url.startsWith("https://fes.rakuten-bank.co.jp/MS/main/RbS?CurrentPageID=START&&COMMAND=LOGIN"), async (page) => { | |
await page.waitForSelector("input[type='submit']:not([disabled])"); | |
await page.type("#LOGIN\\3AUSER_ID", userId); | |
await page.type("#LOGIN\\3ALOGIN_PASSWORD", loginPassword); | |
await page.click("input[type='submit']"); | |
}) | |
.andIf("https://fes.rakuten-bank.co.jp/MS/main/fcs/rb/fes/jsp/mainservice/Security/LoginAuthentication/Login/Login.jsp", async (page) => { | |
await page.waitForSelector("input[type='submit']:not([disabled])"); | |
await page.type("#INPUT_FORM\\3AINPUT_BRANCH_CODE", branchCode); | |
await page.type("#INPUT_FORM\\3AINPUT_ACCOUNT_NUMBER", accountNumber); | |
const formText = await page.$eval("#INPUT_FORM", form => form.innerText); | |
for (let q in secretWords) { | |
if (formText.indexOf(q) >= 0) { | |
await page.type("#INPUT_FORM\\3ASECRET_WORD", secretWords[q]); | |
} | |
} | |
await page.click("input[type='submit']"); | |
}) | |
.andIf(url => url.startsWith("https://fes.rakuten-bank.co.jp/MS/main/gns?COMMAND=BALANCE_INQUIRY_START"), async (page, walker) => { | |
const totalAmount = await page.$eval(".innercellsmall .smediumbold", n => n.parentNode.innerText); | |
console.log(totalAmount); | |
await walker.finish(); | |
}) | |
.startWalking(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment