Jump to content

[SOLVED]Hello I need to print out some text that changes value from a .html


Recommended Posts

Hello everyone, I want to print out a part of my .html file.
the .html contains this part in particular and the amount changes value if a lead is generated on the particular network.

 

<a id="live_holder" style="width:186px; height: 46px;" href="panels_stats_breakdown_daily.php?tool_view=&date_view=today" title="" class="amount"> <span class="">Today's Revenue:</span><br/><img title="Updated live every 120 seconds." class="tipW" id="live_img" src="images/transmit_blue.png"><span class="balanceAmount" id="today_live">$35.90</span> </a>

The autoIT code so far!

; The data to be sent
$sPD = 'login=true&email=&pwd=&redirect_to='
; Post data/User information - You gotta update csrftoken if it reports errors / 404 codes

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "https://www.cpagrip.com//admin/index.php", False) ; Post url
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data >
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("Referer", "https://www.cpagrip.com/admin/panels_login.php")
; Header data <
; Performing the Request
$oHTTP.Send($sPD)
;Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
$oAmount = $oHTTP.

If $oStatusCode <> 200 then
 MsgBox(4096, "Response code", $oStatusCode)
EndIf

; Saves the body response regardless of the Response code
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
 FileClose($file)

Now I would very much like to print out the amount (in this case 35.90) inside a gui or something and loop it so it updates ever 2 minutes, this is simply a software that would benefit me and many other users on CPAGRIP, can you help me?

 

 

 

 

 

Edited by RyukShini
Link to comment
Share on other sites

Should be able to easily get the raw html with _IEBodyReadHTML()

https://www.autoitscript.com/autoit3/docs/libfunctions/_IEBodyReadHTML.htm

Then throw that through RegEx or something to pull the data you want.

#Include <Array.au3>

$sString = '<a id="live_holder" style="width:186px; height: 46px;" href="panels_stats_breakdown_daily.php?tool_view=&date_view=today" title="" class="amount"> <span class="">Today' & 's Revenue:</span><br/><img title="Updated live every 120 seconds." class="tipW" id="live_img" src="images/transmit_blue.png"><span class="balanceAmount" id="today_live">$35.90</span> </a>'
$aRegEx = StringRegExp($sString, 'today_live">([^<]+)<', 3)
_ArrayDisplay($aRegEx)

I'm sure there are better ways, and most often its recommended to not use RegEx for HTML but assuming that the format does not change on the page I think this would work.

Link to comment
Share on other sites

Should be able to easily get the raw html with _IEBodyReadHTML()

https://www.autoitscript.com/autoit3/docs/libfunctions/_IEBodyReadHTML.htm

Then throw that through RegEx or something to pull the data you want.

#Include <Array.au3>

$sString = '<a id="live_holder" style="width:186px; height: 46px;" href="panels_stats_breakdown_daily.php?tool_view=&date_view=today" title="" class="amount"> <span class="">Today' & 's Revenue:</span><br/><img title="Updated live every 120 seconds." class="tipW" id="live_img" src="images/transmit_blue.png"><span class="balanceAmount" id="today_live">$35.90</span> </a>'
$aRegEx = StringRegExp($sString, 'today_live">([^<]+)<', 3)
_ArrayDisplay($aRegEx)

I'm sure there are better ways, and most often its recommended to not use RegEx for HTML but assuming that the format does not change on the page I think this would work.

Perfect!
I clearly understand what to do next, as soon as I have finished it I will test and write back results and solutions!

Thank you!

Link to comment
Share on other sites

Should be able to easily get the raw html with _IEBodyReadHTML()

https://www.autoitscript.com/autoit3/docs/libfunctions/_IEBodyReadHTML.htm

Then throw that through RegEx or something to pull the data you want.

#Include <Array.au3>

$sString = '<a id="live_holder" style="width:186px; height: 46px;" href="panels_stats_breakdown_daily.php?tool_view=&date_view=today" title="" class="amount"> <span class="">Today' & 's Revenue:</span><br/><img title="Updated live every 120 seconds." class="tipW" id="live_img" src="images/transmit_blue.png"><span class="balanceAmount" id="today_live">$35.90</span> </a>'
$aRegEx = StringRegExp($sString, 'today_live">([^<]+)<', 3)
_ArrayDisplay($aRegEx)

I'm sure there are better ways, and most often its recommended to not use RegEx for HTML but assuming that the format does not change on the page I think this would work.

Is it only possible with IE?
Not really what I was looking for, but i'll do it if nothing else is possible!

Link to comment
Share on other sites

I did like this and it works flawlessly.
 

; Saves the body response regardless of the Response code
 $file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
 FileWrite($file, $oReceived)
$read = FileRead("Received.html") ;read file
$Datastring = ('today_live">')
$readamount = _StringBetween($read,$Datastring, "</span>") ;read title from file
MsgBox(0,"",$readamount[0]) ;display first found string

Now I would very much like to loop this and(and only if) the amount/value has changed(I have received more money on cpa) _SoundPlay MY SOUND etc.

anyone who can help me with that?

Thanks in advance.

Edited by RyukShini
Link to comment
Share on other sites

I was reading through this yesterday and ran out of time to look at it thoroughly, but if your original code is solid (I couldn't really test), then this should keep the program looping every 2 minutes, and it sets up a comparison and will play a sound and pop up a message box if the amount goes higher on the next scan.

#include <String.au3>
#include <Array.au3>
$oldreadamount = 0
While 1 ; <--- start a loop to keep prog going
    
; The data to be sent
$sPD = 'login=true&email=&pwd=&redirect_to='
; Post data/User information - You gotta update csrftoken if it reports errors / 404 codes

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "https://www.cpagrip.com//admin/index.php", False) ; Post url
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data >
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("Referer", "https://www.cpagrip.com/admin/panels_login.php")
; Header data <
; Performing the Request
$oHTTP.Send($sPD)
;Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
$oAmount = $oHTTP.

If $oStatusCode <> 200 then
 MsgBox(4096, "Response code", $oStatusCode)
EndIf

; Saves the body response regardless of the Response code
$file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
FileWrite($file, $oReceived)
$read = FileRead("Received.html") ;read file
$Datastring = ('today_live">')
$newreadamount = _StringBetween($read,$Datastring, "</span>") ;read title from file
$newreadamount[0] = StringReplace($newreadamount[0], "$", "") ; taking out the $ makes it easier to compare values

If $newreadamount[0] > $oldreadamount Then
 SoundPlay(@WindowsDir & "\media\tada.wav", 1)
 MsgBox(0,"More Money Coming in!",$newreadamount[0]) ;display first found string
EndIf

Sleep(120000) ; wait 2 minutes before looking again
$oldreadamount = $newreadamount[0]

WEnd

 

Edited by MuffinMan
Link to comment
Share on other sites

I was reading through this yesterday and ran out of time to look at it thoroughly, but if your original code is solid (I couldn't really test), then this should keep the program looping every 2 minutes, and it sets up a comparison and will play a sound and pop up a message box if the amount goes higher on the next scan.

#include <String.au3>
#include <Array.au3>
$oldreadamount = 0
While 1 ; <--- start a loop to keep prog going
    
; The data to be sent
$sPD = 'login=true&email=&pwd=&redirect_to='
; Post data/User information - You gotta update csrftoken if it reports errors / 404 codes

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "https://www.cpagrip.com//admin/index.php", False) ; Post url
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data >
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("Referer", "https://www.cpagrip.com/admin/panels_login.php")
; Header data <
; Performing the Request
$oHTTP.Send($sPD)
;Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
$oAmount = $oHTTP.

If $oStatusCode <> 200 then
 MsgBox(4096, "Response code", $oStatusCode)
EndIf

; Saves the body response regardless of the Response code
$file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
FileWrite($file, $oReceived)
$read = FileRead("Received.html") ;read file
$Datastring = ('today_live">')
$newreadamount = _StringBetween($read,$Datastring, "</span>") ;read title from file
$newreadamount[0] = StringReplace($newreadamount[0], "$", "") ; taking out the $ makes it easier to compare values

If $newreadamount[0] > $oldreadamount Then
 SoundPlay(@WindowsDir & "\media\tada.wav", 1)
 MsgBox(0,"More Money Coming in!",$newreadamount[0]) ;display first found string
EndIf

Sleep(120000) ; wait 2 minutes before looking again
$oldreadamount = $newreadamount[0]

WEnd

 

Very great work!
It works as expected for now I believe.
I will be coding more similar web based stuff, AutoIT is just perfect for it!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...