VB/VB.Net Récupere une info de la page

Inscrit
21 Février 2012
Messages
81
Reactions
5
#1
Après la connexion réussite j'aimerais récupéré quel que information du genre j'ai 35 de pierre etc ...
J'ai monter un petit code le voici :

Code:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        WebBrowser1.Document.GetElementById("login_player").SetAttribute("value", TextBox1.Text)
        WebBrowser1.Document.GetElementById("login_passwd").SetAttribute("value", TextBox2.Text)
        Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

        For Each webpageelement As HtmlElement In allelements

            If webpageelement.GetAttribute("type") = "submit" Then

                webpageelement.InvokeMember("click")

            End If

        Next

      
        Dim sString As String = "<span class=""marginRight10"" max=""1323"" warn=""1058"" start=""19.751582791513"" prod=""52"" id=""stone"" title=""52 par heure"">0</span>"
        Dim sStart As String = "<span class=""marginRight10"" max=""1323"" warn=""1058"" start=""19.751582791513"" prod=""52"" id=""stone"" title=""52 par heure"">"
        Dim sEnd As String = "</span>"

        Label8.Text = GetBetweenRegex(sString, sStart, sEnd)

    End Sub
    Private Function GetBetweenRegex(ByVal sString As String, ByVal sStart As String, ByVal sEnd As String) As String
        Dim oRegex As New Regex(sStart & "(.+?)" & sEnd)
        Dim oMatch As Match = oRegex.Match(sString)

        If oMatch.Success = True Then
            Return oMatch.Groups(1).ToString()
        End If
        Return Nothing
    End Function
Le truc c'est que sa fonctionne pas si vous pouviez m'aider sa sera sympas merci :)

Cordialement , MrFrag
 
A

Anonymous

Invité
#2
J'avais cherche a faire ceci ya longtemps mais je comprenais rien au post sur le net.

Essaye un truc de ce genre, cela devrait marcher.

Private Function GetBetween(ByVal Input As String, ByVal StartString As String, ByVal EndString As String) As MatchCollection
Return Regex.Matches(Input, Regex.Escape(StartString) & "(?<data>.*?)" & Regex.Escape(EndString))
End Function
 
Haut Bas