Jump to content
Sign in to follow this  
feat

Reading value out of inet source code

Recommended Posts

feat

Hi guys, I try to write a program that reads a value out of the scource code of a url, I'll show you what I tried so far

#include <INet.au3>
#include <String.au3>
Dim $sloc, $body, $armory
$Find = "arcane value" 

ConsoleWrite(_INetGetSource('http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Athenel%C3%B3l'))
$body = ConsoleRead()
$sloc = @TempDir & "\stest.txt"

FileWrite($sloc, $body)
$sfile = FileOpen($armory, 0)
$num = 0
While 1 
     $num = $num + 1
    $sline = FileReadLine($sfile, $num)
      If StringInStr($sline, $Find) Then
                ;didnt even try
                ExitLoop
            EndIf
        WEnd

Well, what I actually try is to get, this part "<arcane value="2022"/>" (just the number (2022)) out of the scource code w/o opening IE or other stuff. This program seem to stuck @ ConsoleRead(), I dont even think, that ConsoleRead() is the right way to go for.

I would be really thankful if anyone out there could help me!

Share this post


Link to post
Share on other sites
Valuater

This works.... BUT, there is no "<arcane value=" on this page

; demonstration to find chracters that change between to standard points
; or just find a string
#include <IE.au3>
#include <String.au3>
#include <INet.au3>
#Region --- IE-Builder generated code Start ---

;$oIE = _IECreate()

;------------- User input --------------
$Web_Site = 'http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Athenel%C3%B3l' ; web address
$Find = "this.arcane="  ; my info shows after this line... or just find this line
$Before = ";"     ; my info shows before this line... or set as ""
; ------------ End User input -------------
Sleep(1000)
$body = _INetGetSource($Web_Site)
;Run("notepad.exe")
;WinWaitActive("")
;ControlSetText("Untitled", "", "Edit1", $body)
$sloc = @TempDir & "\stest.txt" 
FileDelete($sloc)
FileWrite($sloc, $body)
$sfile = FileOpen($sloc, 0)
$num = 0
While 2
    $num = $num + 1
    $sline = FileReadLine($sfile, $num)
    If @error Then
        MsgBox(262208, "Fail", "The string was NOT found   ")
        FileClose($sfile)
        Exit
    EndIf
    If StringInStr($sline, $Find) Then
        MsgBox(64, "Success", "The string " & $Find & " was found    " & @CRLF & " on line # " & $num, 5)
        If $Before = "" Then ExitLoop
        $Found = _StringBetween($sline, $Find, $Before)
        MsgBox(64, "Found", "The string is *" & $Found[0] & "*    ", 5)
        ExitLoop
    EndIf
WEnd

#EndRegion --- IE-Builder generated code End ---

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
feat

ty for the answer, but this way, he will open IE, what I rly dislike, is there another way? and btw what do I have to do after I found "this.arcane". I am rly bad at programming, never did so far, ty for your help

Share this post


Link to post
Share on other sites
Valuater

ty for the answer, but this way, he will open IE, what I rly dislike, is there another way? and btw what do I have to do after I found "this.arcane". I am rly bad at programming, never did so far, ty for your help

That did not open IE... I had changed it from an IE Lesson in Welcome to Autoit 1-2-3

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
feat

#include <Array.au3>
#include <INet.au3>

Dim $sURL = 'http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Athenel%C3%B3l'
Dim $sSrc = _INetGetSource($sURL)
Dim $aMatch = StringRegExp($sSrc, '(?i)this.arcane=(\d+);', 1)
If IsArray($aMatch) Then _ArrayDisplay($aMatch)
sry for being that stupid, now I got the value (2022 in this case) in an array, how do I get it into a variable so I can do smth. like this

MsgBox(0,"",$Arcane)

so that $Arcane = 2022 in this case

ty for ur help so far

edit:

Dim $sURL = 'http://eu.wowarmory.com/character-sheet.xml?r=Stormscale&n=Athenel%C3%B3l'
Dim $sSrc = _INetGetSource($sURL)
Dim $aMatch = StringRegExp($sSrc, '(?i)this.arcane=(\d+);', 1)
If IsArray($aMatch) Then _ArrayToClip($aMatch)
MsgBox(0,"",ClipGet())

I've got this so far, but I guess there is a better way

Edited by feat

Share this post


Link to post
Share on other sites
feat

well yea, so I got the first value out of the scource code, nice so far, now I tried to hook off the second one... but I tried and didn't recieve a result, the problem is, if I use the code above, he will get me the wrong value, since "this.effective=" is more than once in there, and its not in first place, can somebody explain me how to let the program get the value right after the 2nd or 3rd "this.effective="

thanks for all the help so far!!!

Share this post


Link to post
Share on other sites
Authenticity

You can use this for example:

Dim $sPattern = '(?i)this.effective="(\d+)"'
Dim $aMatches = StringRegExp($sSrc, $sPattern, 3) ; 3 for global matches.
If IsArray($aMatches) Then _ArrayDisplay($aMaches)

If you want the second or the third you can check if the array size is greater than 2 for example and get the third element for example. Anyway, if you don't want to collect or to match all the occurrences of "this.effective" then you'll need to see in the source what can uniquely identify the "this.effective" occurrence. Maybe it's followed by an expression that is not following any other "this.effective".

Edited by Authenticity

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  

×