Submit form (POST data), possible via the http request node?

1,051 views
Skip to first unread message

Zsolt Nagy

unread,
Jul 9, 2015, 11:54:21 AM7/9/15
to node...@googlegroups.com
Hi everyone,

I'm fairly new to Node-Red, but I'm really excited about what it can be used for, and in my spare time I try to play around with it. : )

TL;DR

I am trying to submit form data (POST) to a remote site by the means of the http request node (it's essentially a login, but it doesn't work with basic auth.)
Is there an easy way to do mimic a form submission through the request node, or by other means, possibbly another node that I don't know of? Where can I start researching to achieve this?

I'd really appreciate if you could help or offer any kind of advice.

Details below:

Recently I had an idea to make my finances more transparent and trackable. Of course there are numerous applications capable of tracking financial accounts by means of recording transactional data by hand, but I'm thinking of automating this by tracking my balance and automatically recording changes over time.

Every account I have has a very easy form for querying balance, and I thought of using the http request node to log in and retrieve my balance, but I'm not sure if a form submission to a remote site (by means of POST data) can be trivially achieved. At least for me it wasn't. I tried to pipe the form POST data through my localhost and see what's inside, but it was extremely long and cluttered and even if I reused it, it didn't work, because it seemed JSON, but had several syntax errors around Function keywords.

I'm thinking that the site uses cookies, or some kind of another magic which prevents me from just sending the field data to the action URL via POST and except to get a proper response, but I'm not sure. Where I'm trying to log in like this is this site:

https://www.otpbank.hu/portal/hu/Egyenleglekerdezes (OTP Bank Balance Inquiry, Hungary)

Here's the source code of the form on the site that I'd like to submit:

<form onsubmit="this.azonosito.value=this.azonositoxx.value; this.azonositoxx.value=''; this.telekod.value=this.telekodxx.value; this.telekodxx.value='';" name="bankkartyasBejelentkezesForm" method="post" id="bankkartyasBejelentkezesForm" action="https://www.otpbankdirekt.hu/homebank/do/bankkartyaEgyenlegLekerdezes">
  <input value="login" type="hidden" name="muvelet"/>
  <input value="" type="hidden" name="azonosito"/>
  <input value="" type="hidden" name="telekod"/>
  <input value="Default.User" type="hidden" name="honlapAzonosito"/>
  <input type="hidden" name="lang" value="hu"/>
  <div class="row">
<label for="azonositoxx_egyenleg">Kártyaszám utolsó 10 számjegye:</label>
<input type="text" name="azonositoxx" maxlength="10" id="azonositoxx_egyenleg"/>
  </div>
  <div class="row">
<label for="telekodxx_egyenleg">Telekód (alapesetben a számlaszám utolsó 3 számjegye):</label>
<input type="password" name="telekodxx" maxlength="3" id="telekodxx_egyenleg" autocomplete="off"/>
  </div>
  <div class="btn green">
<ul>
  <li>
<input type="submit" onclick="_gaq.push(['_trackEvent', 'Egyenleg', 'Button', 'Login']);" value="Belépés"/>
  </li>
</ul>
  </div>
</form>


The form that I'm talking of is the two field form unter the text "Egyenleglekérdezés" (meaning balance inquiry, whatever :D)
The first field needs to contain 10 digits of one's credit card and the second is a secret so-called telecode.

What I realized that these two fields are called azonositoxx and telekodexx, and before submission they get copied into azonosito and telekod, so actually these two (hidden) fields should be used for submission.
There are also other fields in the form like method with the value login, and others.

Cheers,
Zsolti

Walter Kraembring

unread,
Jul 10, 2015, 1:44:51 AM7/10/15
to node...@googlegroups.com
I have only done similar things in Python but this article could maybe help (you could consider putting your javascript code into a function node)

A second thought, if you can do transferring once you are logged on, should you consider changing bank if they only require user name and password to logon to your account?

Walter Kraembring

unread,
Jul 10, 2015, 2:57:51 AM7/10/15
to node...@googlegroups.com
I meant template node

Julian Knight

unread,
Jul 10, 2015, 6:24:21 AM7/10/15
to node...@googlegroups.com
I think that you need to look more closely at the JavaScript that is being called when you push the submit button. You may find additional security measures in there.

In principal, you can certainly do a POST using the request node so it should be possible. The other thing you could do would be to use a development proxy to capture the transaction when you submit. That way you can be sure of what is going over the wire.

Nicholas O'Leary

unread,
Jul 10, 2015, 7:03:40 AM7/10/15
to node...@googlegroups.com

You may also find the page has set session cookies to prevent exactly this type of request. You would be better off working out the series of requests you need to make using a tool like curl first, then translate that to the appropriate node-red flows.

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zsolt Nagy

unread,
Jul 10, 2015, 10:25:36 AM7/10/15
to node...@googlegroups.com
Hi Walter,

Thank you for the code, I'll see into it and thank you for your concern, too. This site is not meant for account management, it's just a balance query, nothing else, so no transactions can be performed after logging in.

Hi Julian,

Thanks for the heads up, I looked at the code that's being called, but it seemed to me that it's just a visitor or other kind of tracking code. (https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gaq)

Hi Nick,

Now that's something that I feared. How will curl help me understand what's going on under the hood?

Thanks,
Zsolti
Reply all
Reply to author
Forward
0 new messages