Jump to content

Issues with InetRead, BinaryToString, and StringBetween


xiantez
 Share

Recommended Posts

Hello AutoIT community. 

I am attempting to make a script that will login to my bank account and retrieve one of my account balances and display it in a MsgBox, however it am having some difficulty getting the correct value.... The MsgBox keep displaying a value of "0" instead of the actual string in between the source code I'm looking for.... Any help would be greatly appreciated!

$readtext = InetRead("https://www.xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&LOB=CONS",1)
$source = BinaryToString($readtext)
$text =  _StringBetween($source,'CHECKING XXXXXXXXXX ', ' "> ')


MsgBox(0,"balance",$text)     ;This keeps returning a value of "0"


        Case $GUI_EVENT_CLOSE
           GUIDelete($Form1)
            ExitLoop
         Case $Button2
            GUIDelete($Form1)
            ExitLoop
    EndSwitch
WEnd

 

 

Link to comment
Share on other sites

HI.   _StringBetween return an array.

try this way to see whole array.

$readtext = InetRead("https://www.xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&LOB=CONS",1)
$source = BinaryToString($readtext)
$text =  _StringBetween($source,'CHECKING XXXXXXXXXX ', ' "> ')



_ArrayDisplay($text)


        Case $GUI_EVENT_CLOSE
           GUIDelete($Form1)
            ExitLoop
         Case $Button2
            GUIDelete($Form1)
            ExitLoop
    EndSwitch
WEnd

You should include #include <Array.au3>  for use _arraydisplay

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

Hi DanyFirex,

Thank you for your suggestion, however when i use _ArrayDisplay($text) I do not see anything on my screen.... Is there another command i need to do to see this text pop up? Here is what I have now

 

$readtext = InetRead("https:/xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&amp;LOB=CONS",1)
$source = BinaryToString($readtext)
$text =  _StringBetween($source,'CHECKING XXXXXXXXXX&nbsp;','">')

_ArrayDisplay($text)

Edited by xiantez
Link to comment
Share on other sites

If the _ArrayDisplay() function doesn't show anyting is because $text is not an array, and if is not an array is because the _StringBetween() function has found nothing.
Perhaps the start and end parameters that you use in the _StringBetween() function will not catch any string, try to use only "'CHECKING" as The beginning of the string to find and see if it will catch something.
Try this snippet to do a little debug:

#include <Array.au3>
#include <String.au3>

$readtext = InetRead("https:/xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&amp;LOB=CONS", 1)
$source = BinaryToString($readtext)
$text = _StringBetween($source, 'CHECKING', '">')

If Not IsArray($text) Then
    MsgBox(0, "Debug", "No string found by _StringBetween()")
Else
    _ArrayDisplay($text)
EndIf

 

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Have you checked the result of InetRead?

 
$readtext = InetRead("https://www.xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&amp;LOB=CONS",1)
 $source = BinaryToString($readtext)
MsgBox(0,"Whole Text",$source)     ;This keeps returning a value of "0" 
 
 $text =  _StringBetween($source,'CHECKING XXXXXXXXXX&nbsp;', ' "> ') 


 MsgBox(0,"balance",$text[0])     ;This keeps returning a value of "0"

 

Link to comment
Share on other sites

try to create a file with downloaded data and check if the field you need exist.

 

Saludos

Link to comment
Share on other sites

9 hours ago, Chimp said:

If the _ArrayDisplay() function doesn't show anyting is because $text is not an array, and if is not an array is because the _StringBetween() function has found nothing.
Perhaps the start and end parameters that you use in the _StringBetween() function will not catch any string, try to use only "'CHECKING" as The beginning of the string to find and see if it will catch something.
Try this snippet to do a little debug:

#include <Array.au3>
#include <String.au3>

$readtext = InetRead("https:/xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&amp;LOB=CONS", 1)
$source = BinaryToString($readtext)
$text = _StringBetween($source, 'CHECKING', '">')

If Not IsArray($text) Then
    MsgBox(0, "Debug", "No string found by _StringBetween()")
Else
    _ArrayDisplay($text)
EndIf

 

I think you are on to something Chimp.... My MsgBox was triggered due to not finding a string in the $source.... interesting....

I have questioned whether or not my InetRead is working properly.... I am not sure what source code I should be using now, i figured I could just log into my account, right click the main page and "get source code" would suffice..... I guess not.... =\ 

Link to comment
Share on other sites

7 hours ago, AutoBert said:

Have you checked the result of InetRead?

 
$readtext = InetRead("https://www.xxxbanksitexxx.com/das/cgi-bin/session.cgi?screenid=SIGNON_PORTAL_PAUSE&amp;LOB=CONS",1)
 $source = BinaryToString($readtext)
MsgBox(0,"Whole Text",$source)     ;This keeps returning a value of "0" 
 
 $text =  _StringBetween($source,'CHECKING XXXXXXXXXX&nbsp;', ' "> ') 


 MsgBox(0,"balance",$text[0])     ;This keeps returning a value of "0"

 

AutoBert,

I am going to do this next... Thanks!!!

Link to comment
Share on other sites

Well.... This is strange.....

I checked the results of my InetRead and used WriteFile.... The source code is not at all what I expected.... It is not even the same source code that I see when I "view source code" from my browser.... Grrrr, thats annoying lollll

I could only imagine they might be embedding this stuff into an applet or something... I did notice that when i view my checking account, the session ID in the URL changes constantly.... This is pretty standard in embedded applications via web front ends... I have no clue how to get around that though....

Here are the results of my INetRead when i write it into an html file...

 

2016-01-24_11-55-25.png

Edited by xiantez
Link to comment
Share on other sites

Link to comment
Share on other sites

5 minutes ago, Danyfirex said:

Of course. you need credentials. try to use  IE.

Saludos

Yes, my script  already knows how to log in and pass credentials.... that part works fine.... it not until it attempts to retrieve the source code is when i get those INetResults... I need to find a way to attach it to an existing session ID.... Because when my script makes the INetRead or _IEGetSource call, the website doesn't recognize the call from an existing session ID, thus timing me out....

I did find a work around using the following code

$rText = _IEBodyReadText($oIE)

FileWrite("source.txt",$rText)

Then I can just read the text from the file and output it to a msgbox.... Not my ideal way of doing it, but it works for now...

Link to comment
Share on other sites

You dont need to write to a file. you can use  $rText  with _StringBetween

 

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...