Sign in to follow this  
Followers 0
Jack023

Read text from site.

21 posts in this topic

Hey all,

I'm trying to read a text from my site.

Only text there can be is On or Off

and tryed to make a if statement with no luck :(

site=: http://jackclania.netai.net/test2.php

#include <IE.au3>

$i = 1
Do
    sleep(3000)
    $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0)
    $sHTML = _IEBodyReadText($oIE)
    MsgBox(0, "status", "status = " & $sHTML)
    If _IEBodyReadText($oIE) = "on" then
    Do
        MsgBox(0, "ON", "status = ON")
        $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0)
        $sHTML = _IEBodyReadText($oIE)
    Until $sHTML = "off"
ElseIf _IEBodyReadText($oIE) = "on" then
    Do
    MsgBox(0, "OFF", "status = OFF")
    $oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0)
    $sHTML = _IEBodyReadText($oIE)
    ProcessClose("iexplore.exe")
    MsgBox(0, "ON", "status = on")
    Until $sHTML = "on"
EndIf
Until $i = 0

Thanks in advance :))

Share this post


Link to post
Share on other sites



Maybe...

 
#include <IE.au3>
 
$oIE = _IECreate("http://jackclania.netai.net/test2.php");, "", 0)
 
HotKeySet("{ESC}", "Terminate")
 
While 1
Sleep(3000)
 
$sHTML = _IEBodyReadText($oIE)
MsgBox(0, "status", "status = *" & $sHTML & "*"); note there is a return in here
 
If StringInStr($sHTML, "on") Then
MsgBox(0, "ON", "status = ON")
_IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=off")
 
Else
MsgBox(0, "OFF", "status = OFF")
_IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=on")
 
EndIf
 
WEnd
 
Func Terminate()
_IEQuit($oIE)
Exit 0
EndFunc   ;==>Terminate
 
 

NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

works good, only the  _ienavigate was not needed.

Only i want that after it checked like if it's on, it keeps checking it untill its OFF and then restart the previous loop again.

It's now like this:

#include <IE.au3>

$oIE = _IECreate("http://jackclania.netai.net/test2.php", "", 0);, "", 0)

HotKeySet("{ESC}", "Terminate")

While 1
sleep(3000)
$sHTML = _IEBodyReadText($oIE)
MsgBox(0, "status", "status = *" & $sHTML & "*"); note there is a return in here

If StringInStr($sHTML, "on") Then
MsgBox(0, "ON", "status = ON")
;~ _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=off")

Else
MsgBox(0, "OFF", "status = OFF")
;~ _IENavigate($oIE, "http://jackclania.netai.net/test2.php?set=on")

EndIf

WEnd

Func Terminate()
_IEQuit($oIE)
Exit 0
EndFunc   ;==>Terminate
Edited by Jack023

Share this post


Link to post
Share on other sites

bump 

Share this post


Link to post
Share on other sites

Nobody knows? Lol

Share this post


Link to post
Share on other sites

Hey all,

I'm trying to understand how winhttp works.

I'm trying to read the text on this page , can be on or off. but want this in a loop.

http://jackclania.netai.net/status // this is the site where you need read from.

Tried many things but nothing works, any tips?

Share this post


Link to post
Share on other sites

Tip #1: Post your code.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

He did,> here...

@Jack023 - Stick to one thread.  If you are not getting Help it is either because you have not posted enough info or expertise is not available.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Well , it was meant to that thread, but found out that winhttp is better then IE.au3 , so thats why i came here, will post new code her soon ;) 

Share this post


Link to post
Share on other sites

#include "WinHttp.au3"

$text = 0 // when i removed this it gave a error.

    Opt("MustDeclareVars", 1)

    ; Initialize and get session handle
    Global $hOpen = _WinHttpOpen()
    ; Get connection handle
    Global $hConnect = _WinHttpConnect($hOpen, "http://jackclania.netai.net/status")

$text = _WinHttpSimpleRequest($hConnect, "GET", "http://jackclania.netai.net/status")
MsgBox(0, "", $text)

    ; Close handles
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

but what i need is read if it's on or off on the page http://jackclania.netai.net/status

Share this post


Link to post
Share on other sites

There are several ways

$url = "http://jackclania.netai.net/status"

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
; or :
; $oHTTP = ObjCreate("Microsoft.XMLHTTP")
$oHTTP.Open("GET", $url, 0)
$oHTTP.Send()
Local $txt = $oHTTP.Responsetext 
$oHTTP = 0
Msgbox(0,"", $txt)

; else
Msgbox(0,"", BinaryToString(InetRead($url, 1)))

or _InetGetSource, etc

Share this post


Link to post
Share on other sites

Jack023,

Threads merged - please stick to just the one at a time in future. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#include "WinHttp.au3"

$text = 0

    Opt("MustDeclareVars", 1)

    ; Initialize and get session handle
    Global $hOpen = _WinHttpOpen()
    ; Get connection handle
    Global $hConnect = _WinHttpConnect($hOpen, "http://jackclania.netai.net/status")

$text = _WinHttpSimpleRequest($hConnect, "GET", "http://jackclania.netai.net/status")
MsgBox(0, "", $text)

    ; Close handles
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

Alright, i heard that i could use winhttp instead of IE.

So i try to read on the page: http://jackclania.netai.net/status if the message is ON or off , it can be both.

I want this in a loop but the script above dont work.

Greets,

Jack

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

$url = "http://jackclania.netai.net/status"

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
; or :
; $oHTTP = ObjCreate("Microsoft.XMLHTTP")
$oHTTP.Open("GET", $url, 0)
$oHTTP.Send()
Local $txt = $oHTTP.Responsetext 
$oHTTP = 0
Msgbox(0,"", $txt)

; else
Msgbox(0,"", BinaryToString(InetRead($url, 1)))

worked fine for me, thanks !

Does it also work when the pc don't have internet explorer?

Edited by Jack023

Share this post


Link to post
Share on other sites

Do you mean another default browser? Have you tried it?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Well it just works for now as i wanted. Huge thanks !!
only my question was, what if the pc dont have internet explorer. 

Does it still work then?

Share this post


Link to post
Share on other sites

And as I asked before, you need to clarify what you mean by "don't have internet explorer". Do you mean when the person is using a different browser, or has internet explorer actually been disabled altogether?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

When they are not able to surf using ANY browser , like they dont have IE, Chrome and Firefox at all.

Share this post


Link to post
Share on other sites

Still trying to understand under what circumstance you would have a user in that situation. It takes a lot to disable all web browsers on a Windows machine. My question from post #15 still stands; since you obviously have a specific scenario in mind, have you tried to duplicate it yourself?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Well it's alright ! 

This thread is done for me !

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
Sign in to follow this  
Followers 0