Skip to content

Instantly share code, notes, and snippets.

@winguse
Created May 27, 2019 01:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winguse/0fe553a689016427658125e37bf48126 to your computer and use it in GitHub Desktop.
Save winguse/0fe553a689016427658125e37bf48126 to your computer and use it in GitHub Desktop.
// 1. open https://xyk.cmbchina.com
// 2. login with your credential
// 3. paste the following into your browsers console:
var sessionId = '';
const getBody = month => `{"actionName":"getMonthlyDetailBill.do","x_traceid":"webapp","x_mchannel":"webapp","x_caller":".0","userSessionId":"${sessionId}","billDate":"${month}","businessType":"Normal"}`;
const selectedFields = [
'amnt',
'anOrg',
'cardNo',
'desc',
'effectiveDte',
'postingDte',
'txnCurrAmt',
];
const data = [];
const getData = month => {
fetch('https://xyk.cmbchina.com/getMonthlyDetailBill.do', {
headers: {
'Content-Type' : 'application/json;charset=UTF-8',
},
credentials: 'include',
body: getBody(month),
method: 'POST'
})
.then(res => res.json())
.then(json => {
json.data.detail.forEach(d => {
const item = {};
selectedFields.forEach(field => {
item[field] = d[field];
});
data.push(item);
})
});
};
// 4. run the following to get monthly data
getData("201705")
// 5. run the following to export the data into tab splitted text
data
.map(item =>
selectedFields.map(k => item[k]).join('\t')
)
.join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment