xiantez

Issues with InetRead, BinaryToString, and StringBetween

15 posts in this topic

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

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

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

Share this post


Link to post
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"

 

Share this post


Link to post
Share on other sites

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

 

Saludos

Share this post


Link to post
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.... =\ 

Share this post


Link to post
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!!!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Saludos

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

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

 

Saludos

Share this post


Link to post
Share on other sites
3 minutes ago, Danyfirex said:

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

 

Saludos

Haha funny you said that... I just realized that... make those changes now! =)

Share this post


Link to post
Share on other sites

I finally got the _ArrayDisplay to work... However it is putting the entire string in 1 row 1 column....

How do I manipulate the rows and colums so I can have a row for each account (checking, saving, ect)

 

Share this post


Link to post
Share on other sites

You can use _arrayadd

 

Saludos

Share this post


Link to post
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

  • Similar Content

    • rootx
      By rootx
      There is a way to have a clean string value without any SOH STX etc... Values
       
      #include <FileConstants.au3> #include <String.au3> #include <WinAPI.au3> #include <Array.au3> #include <File.au3> $file = _FileListToArrayRec(@ScriptDir,"*.otf",1,1,0,2) For $x = 1 to UBound($file)-1 ;ConsoleWrite(_ReadOffSet($ISO[$x],0x000000,12)) ConsoleWrite(_HexToString(StringStripWS(_ReadOffSet($file[$x],0x000000,16), 8))&@CRLF) $String = StringReplace(BinaryToString(_ReadOffSet($file[$x],0x000000,16)), Chr(0), "") FileWrite(@ScriptDir&"\file.txt",$String&@CRLF) FileWrite(@ScriptDir&"\file2.txt",_HexToString(StringStripWS(_ReadOffSet($file[$x],0x000000,16), 8))&@CRLF) Next Func _ReadOffSet($sFilePath,$iOffset,$iLen=1) Local $sRet="" Local $hFile=FileOpen($sFilePath,$FO_BINARY) FileSetPos($hFile,$iOffset,$FILE_BEGIN) $sRet=FileRead($hFile,$iLen) FileClose($hFile) Return $sRet EndFunc  
    • Mark917
      By Mark917
      I am trying to extract a date and time from a website using InetRead.  The source for the page I am reading shows the date and time as shown below.  I need to somehow extract the correct date and time from this information.  Is there a function or calculation that will do this?  The source shown here correlates to 15:20 (time) 29.03.17 (date).
      <div class="cell game-date" data-time="1490818800000"> <div class="site__time" data-time="1490818800000"> <div class="time"></div> <div class="date"></div> </div> </div>  
    • carl1905
      By carl1905
      Hi. I'm looking forward to adding another language option for BinaryToString.
      Basically, it only supports ANSI, UTF-8,  UTF16 Little Endian, and  UTF16 Big Endian. https://www.autoitscript.com/wiki/BinaryToString
      Is there any way to adding Shift-JIS(Japanese, CP 932) and EUC-KR(Korean, CP 949)?
    • zxtnt09
      By zxtnt09
      Hi guys,
      * Sorry for my many questions,
      ------------------------------------------------
      i use that and it's true and fine,
      Local $dData = InetRead("http://example.com/my.html",1) $my = BinaryToString(StringReplace($dData, "0A", "0D0A"), 4) now how can i add functions in "my.html" and autoit run that function,
      it's meant when ever "Read" data from website, use that serve as "Autoit Function",
      something like that : 
      In "my.html" we have this : 
      MsgBox (1,"This is from website","this is from website") In script we have this : 
      #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GuiSetState() Local $dData = InetRead("http://example.com/my.html",1) $my = BinaryToString(StringReplace($dData, "0A", "0D0A"), 4) ;this place is for MsgBox from "my.html" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Thanks Alot, 
    • zxtnt09
      By zxtnt09
      Hi guys,
      After i use that, all of thing is good and perfect,
      Local $dData = InetRead("http://example.com/my.html",1) $my = BinaryToString(StringReplace($dData, "0A", "0D0A"), 4) but now how can i reload that after x time ?!
      by this ( top script ) , i need to relunch the script to see modified,
      now! how can i update data after X time !?
      for example : 
      in "my.html" we have number "3" , i try to change it to "5", now we need to relunch script to see "3" => "5",
      how we can use that without relunch script.
      thanks alot and sorry for my bad english & too long question.