twang2218 / node-cba-netbank

Unofficial The Commonwealth Bank of Australia NetBank API wrap for Node.js
Apache License 2.0
75 stars 25 forks source link

Not returning transactions #8

Open dwdickens opened 7 years ago

dwdickens commented 7 years ago

Hi, the script doesn't return any of the transactions. (The list of accounts works great.)

parseTransactions is rejected with the message 'Cannot find transactions in the resp'

I have had a look at the html file that is returned in the log folder. It doesn't have any of the transaction data within it, and if I open the static page in a browser it just shows the spinners.

Please let me know if I can help trouble shoot in any way

twang2218 commented 7 years ago

Thanks for your report. Here are some ways to debug the problem.

DEBUG=node-cba-netbank

The debug information can be printed via DEBUG=node-cba-netbank, so you can try:

DEBUG=node-cba-netbank cba-netbank download -a smart

or if it's not installed globally, and you currently inside the project directory, then you can

DEBUG=node-cba-netbank node src/cli.js download -a smart

Which will download the transactions for account with smart in its name, and will output the debug information, which might contain some exceptions or errors.

Run test case

First, set the username/password in the environment variables:

export NETBANK_USERNAME=12345678
export NETBANK_PASSWORD=YOUR_PASSWORD

then, just run npm run test-debug api. This will run a series test, and will try to login to the netbank, fetch the account list, and retrieve the transactions for the first account. There might have some errors/exceptions in the output, which might help the debug.

The content of ./log/ folder

For the transactions parsing, you can have a look on the <number>-3-response-body.html file with the <title>NetBank - Transactions</title> in it.

If you cannot find the file with Transactions title, then there might be some error happened during access the transaction page.

In that file if you find the transaction page, the regular expression, /({"Transactions":(?:[^;]+))\);/ is used to match the transactions. You can manually search for {"Transactions" in the file to see whether there is any transactions data. If you can find the transactions, then maybe there are some cases not covered by the regex. https://regex101.com/ is very helpful for adjust the regex.

If you cannot find any transactions, then there might be some errors in the pages.

You can check the last -response-body.html file, it might be a partial html file, which might contains the transactions as well, like above, just search {"Transactions" to see whether it contains transactions or not.

I hope these information will help you identify the problem, and I will happy to fix it.

dwdickens commented 7 years ago

Hi, thanks for the helpful debugging instructions.

I have looked at the last -response-body.html file.

It doesn't have {"Transactions" in it. The file is complete (it has the final </html tag), and when I view it is has the spinners and says 'Please wait' in the transaction list. There are no error messages in the page.

I am guessing that the page loads the Transactions data using ajax and this isn't being run.

It worked great in previous version of node-cba-netbank - is there something that has changed in how this page is processed?

cmcnamara87 commented 7 years ago

having the same problem, got this from DEBUG=node-cba-netbank cba-netbank download -a smart

(node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: ENOENT: no such file or directory, open 'log/1502003489950-1-request.json'
(node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: ENOENT: no such file or directory, open 'log/1502003489950-2-response.json'
(node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: ENOENT: no such file or directory, open 'log/1502003489950-3-response-body.html'
  node-cba-netbank parseTitle(): found title => 'Transactions' +780ms
Unhandled rejection Cannot find transactions in the resp
dwdickens commented 7 years ago

Hi Craig, looks like you may need to mkdir a log folder so that the debug info is saved into it. I had to do this as well.

On Sun, 6 Aug 2017 at 5:15 pm, Craig McNamara notifications@github.com wrote:

having the same problem, got this from DEBUG=node-cba-netbank cba-netbank download -a smart

(node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: ENOENT: no such file or directory, open 'log/1502003489950-1-request.json' (node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: ENOENT: no such file or directory, open 'log/1502003489950-2-response.json' (node:18562) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: ENOENT: no such file or directory, open 'log/1502003489950-3-response-body.html' node-cba-netbank parseTitle(): found title => 'Transactions' +780ms Unhandled rejection Cannot find transactions in the resp

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/twang2218/node-cba-netbank/issues/8#issuecomment-320490384, or mute the thread https://github.com/notifications/unsubscribe-auth/AMz25laTMrSMHJkH0oOfIgnJXA5ct3i3ks5sVWgkgaJpZM4ObT3p .

davidmcgregor commented 6 years ago

@dwdickens Have you found a solution to this issue yet? I've got the same issue.

durranitech commented 6 years ago

Me too. Account list working but transaction list not working

sebszocinski commented 6 years ago

Any updates on this? Getting the same issue here

davidmcgregor commented 6 years ago

I found the issue is with the parser.parseTransactionPage function. If I remove it and replace it with: .then(parser.parseForm).then(parser.parseAccountListWithKeys) Then it works.

sebszocinski commented 6 years ago

Thanks @davidmcgregor that did the trick 👍