生活/クレジットカード/為替手数料
の編集
https://over.6pb.info/wiki/?&9f72236b49
[
トップ
] [
編集
|
差分
|
履歴
|
添付
|
リロード
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
-- 雛形とするページ --
(no template pages)
***Amex自動化 [#amex] #pre{{ const puppeteer = require('puppeteer'); const fs = require('fs'); (async() => { const browser = await puppeteer.launch({ //headless: false, args: [ '--no-sandbox', ] }); const page = await browser.newPage(); await page.setViewport({width: 1024, height: 768}); await page.goto('https://global.americanexpress.com/myca/logon/japa/action/LogonHandler?request_type=LogonHandler&Face=ja_JP&inav=jp_utility_login', { waitUntil: 'networkidle2'}); await page.waitForSelector('input#lilo_userName', {waitUntil: 'networkidle2', timeout: 10000}); await page.focus("input#lilo_userName"); await page.type("input#lilo_userName", 'your ID'); await page.focus("input#lilo_password"); await page.type("input#lilo_password", 'your passwd'); await page.click('#lilo_formSubmit'); await page.waitForNavigation({waitUntil: 'load'}); await page.waitForSelector('#balance-summary-table', {waitUntil: 'networkidle2', timeout: 2500}); // カードによって違うので要修正 await page.click('#balance-summary-table tr.recent-debits > td.description > a'); await page.waitForNavigation({waitUntil: 'load'}); await page.waitForSelector('#transaction-table', {waitUntil: 'networkidle2', timeout: 7000}); //tr要素のidを取得。transaction id let tid = await page.$$eval('#transaction-table tr[id]', list => { return list.map(date => date.id); }); let lines = []; // transaction id毎に // 各決済のtrは2段からなる。 // クリックによる展開前と展開後の詳細 // idが違う。 for (let i in tid) { await page.click("#transaction-table tr#" + tid[i] + " td.date"); await page.waitForSelector("#transaction-table tr#" + tid[i] + " + tr p.amount.ng-binding", {waitUntil: 'networkidle2', timeout: 7000}); // 詳細欄のtransaction id取得 // 例: #etd-details-content-AT181580... let dom = '#transaction-table tr#' + tid[i] + ' + tr[id]'; let tidd = await page.$eval(dom, e => e.id); // dateと請求額は1段目のtr dom = 'tr#' + tid[i] + ' td.date span.ng-binding'; let date = await page.$eval(dom, e => e.innerText); //#trans-... > td.date > div > span.ng-binding let shop = await page.$eval("tr#" + tidd + " p.header.ng-binding", e => e.innerText); //#etd-details-content-AT1815... > div > div.etdContent.ng-scope > div.etdBlock.ng-scope > p.header.ng-binding let local = await page.$eval("tr#" + tidd + " p.amount > span:nth-child(1)", e => e.innerText); //#etd-details-content-AT1815... > div > div.etdDetails.ng-scope > div > div:nth-child(2) > p.amount > span:nth-child(1) let curr = await page.$eval("tr#" + tidd + " p.amount > span:nth-child(2)", e => e.innerText); //#etd-details-content-AT181... > div > div.etdDetails.ng-scope > div > div:nth-child(2) > p.amount > span:nth-child(2) dom = 'tr#' + tid[i] + ' td.amount > div > span'; let jpy = await page.$eval(dom, e => e.innerText); //#trans-AT18158... > td.amount > div > span let rate_date = await page.$eval("tr#" + tidd + " div.etdContent.ng-scope > div:nth-child(2) > div > p.ng-binding.ng-scope", e => e.innerText); //#etd-details-content-AT18156... > div > div.etdContent.ng-scope > div:nth-child(2) > div > p.ng-binding.ng-scope let rate = await page.$eval("tr#" + tidd + " p.amount.ng-binding", e => e.innerText); // #etd-details-content-AT181... > div > div.etdDetails.ng-scope > div > div:nth-child(3) > p.amount.ng-binding let line = [date,shop,local,curr,jpy,rate_date,rate].join(','); console.log(line); lines.push(line); } fs.writeFile('amex.csv', lines.join("\n"),(err) => { if (err) throw err; }); //ログアウト await page.click('#jp_utility_login'); await browser.close(); })(); }}
タイムスタンプを変更しない
___paraedit_taxtarea___
テキスト整形のルールを表示する