Dim HTML As String = TextBox1.Text Dim pattern As String = "class=""form-field wide-80"">(.*?) " Dim r As New Regex(pattern, RegexOptions.Singleline) Dim m As Match = r.Match(HTML, HTML.IndexOf("ssTab-domainStatus")) Debug.WriteLine("1 " & m.Groups(1).Value)
Structure SeekInfo Dim PosDebut As Integer Dim PosFin As String Dim nbOccurence As Integer Dim Pattern As String End Structure Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim HTML As String = TextBox1.Text ' ' ' Domain Status: ' Registered And Active Website ' Dim findDomain As String = " " Dim posField As New SeekInfo posField = GetPosHtml(HTML, findField, posDomain.PosFin) If IsNothing(posDomain) Then Exit Sub If posField.PosDebut < 0 Then MessageBox.Show("La balise FIELD est introuvable !") Exit Sub End If Dim endField As String = "<" Dim posEndField As New SeekInfo posEndField = GetPosHtml(HTML, endField, posField.PosFin) If IsNothing(posEndField) Then Exit Sub If posEndField.PosDebut < 0 Then MessageBox.Show("La balise END_FIELD est introuvable !") Exit Sub End If MessageBox.Show(HTML.Substring(posField.PosFin, posEndField.PosDebut - posField.PosFin), "SURPRISE ^^") End Sub Private Function GetPosHtml(ByVal SourceHtml As String, ByVal sPattern As String, Optional ByVal StartPos As Integer 0, Optional ByVal OccurenceCatcher As Integer 1) As SeekInfo If SourceHtml = "" Then Throw New Exception("GetPosHtml() error:" + ControlChars.NewLine & "Aucune source Html disponible pour effectuer une recherche !") Return Nothing End If If sPattern = "" Then Throw New Exception("GetPosHtml() error:" + ControlChars.NewLine & "Aucun critère de recherche n'a été définit !") Return Nothing End If Dim _seek As Integer = 0 Dim _wInfo As New SeekInfo 'trimage ^^ sPattern = sPattern.Trim _wInfo.Pattern = sPattern While Not _seek = -1 _seek = SourceHtml.IndexOf(sPattern, StartPos) If _seek = -1 Then Exit While If _seek >= 0 Then _wInfo.nbOccurence += 1 _wInfo.PosDebut = _seek _wInfo.PosFin = _seek + sPattern.Length If _wInfo.nbOccurence = OccurenceCatcher Then Exit While If (_wInfo.PosFin < SourceHtml.Length) Then _seek += sPattern.Length End If End While Return _wInfo End Function
Dim Focus As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("div") For Each curElement As HtmlElement In Focus Dim controlName As String = curElement.GetAttribute("id").ToString If controlName = "ssTab-domainStatus" Then Dim str2 As String = "x" str2 = curElement.GetAttribute("form-field wide-80") NsTextBox19.Text = str2 End If Next
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question'Le TextBox1 contient: ' ' ' Domain Status: ' Registered And Active Website ' Dim Str As String = TextBox1.Text Dim StrA As String = " " Dim StrB As String = " " NsTextBox19.text = Split(Split(Str, StrA, 2)(1), StrB)(0)
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click 'La ligne qui nous interesse: ' Registered And Active Website ' 'Dans mon fichier A.TXT il y a ton code HTML 'Pattern c'est la chaine a chercher après la découpe 'Avec le code ci-dessous, lorsque l'on arrive à cette balise div 'curRow contient ceci: 'curRow(0) = "" 'curRow(1) = div class="form-field wide-80" 'curRow(2) = Registered And Active Website 'curRow(3) = /div 'curRow(4) = "" ' 'Lorsque je boucle chaque element de la découpe effectué par ReadField 'Si l'element est = au pattern alors affiche: "trouvé" Dim MyReader As New FileIO.TextFieldParser("C:\Users\Duke49\Desktop\a.txt") Dim pattern As String = "Registered And Active Website" MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.TrimWhiteSpace = True MyReader.SetDelimiters(New String() {">", "<"}) MyReader.HasFieldsEnclosedInQuotes = True Dim curRow As String() While Not MyReader.EndOfData curRow = MyReader.ReadFields For Each el As String In curRow If el = pattern Then MessageBox.Show("trouvé") End If Next el End While End Sub
Private Sub TrackWebsite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackWebsite.Click If WebsiteIp.Text.Length > 0 Then Dim url As String = ("http://whois.domaintools.com/" + WebsiteIp.Text) WebBrowser1.Navigate(url) While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete Application.DoEvents() InfoCollector2.Start() WebsiteTracking.Text = WebsiteIp.Text End While Else MsgBox("Please, insert an domain website") End If End Sub
Private Sub InfoCollector2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoCollector2.Tick 'Code à écrire InfoCollector2.Stop() End Sub
je crois qu'on s'éloigne de mon probleme d'origine
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load WebBrowser1.Navigate("http://www.pixelvision.free.fr/") End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted '<title>Cf2i</title> 'Exemple pour récupérer ce qui est entre les balises <title> et </title> Dim Str As String = WebBrowser1.DocumentText Dim BaliseA As String = "<title>" Dim BaliseB As String = "</title>" MsgBox(Split(Split(Str, BaliseA, 2)(1), BaliseB)(0)) End Sub
Dim Str As String = WebBrowser1.DocumentText
NsTextBox19.Text = Split(Split(Str, StrA, 2)(1), StrB)(0)
Dim Str As String = TextBox1.Text Dim StrA As String = " " Dim StrB As String = " " NsTextBox19.text = Split(Split(Str, StrA, 2)(1), StrB)(0)
Domain Status: Registered And Active Website
Dim Str As String = WebBrowser1.DocumentText Dim StrA As String = " " Dim StrB As String = " " NsTextBox19.Text = Split(Split(Str, StrA, 2)(1), StrB)(0)
Dim Str As String = WebBrowser1.DocumentText Threading.Thread.Sleep(1000) Dim StrA As String = " " Dim StrB As String = " " NsTextBox19.Text = Split(Split(Str, StrA, 2)(1), StrB)(0)
NsTextBox19.Text = Split(Split(Str, StrA, 2)(1), StrB)(0)
'Split par défaut, considère les espaces comme séparateur, exemple: Dim Str As String = "Ceci est le texte à découper" For Each Mot In Split(Str) MessageBox.Show(Mot) Next 'Si nous avons un autre séparateur comme la vigule par exemple: Str = "Ceci,est,le,texte,à,découper" For Each Mot In Split(Str, ",") MessageBox.Show(Mot) Next 'Ou par exemple si l'on décide que le séparateur est ":" Str = "Ceci,est,le:texte,à,découper" MessageBox.Show(Split(Str, ":")(0)) 'qui sera: 'Ceci,est,le' MessageBox.Show(Split(Str, ":")(1)) 'qui sera: 'texte,à,découper' 'Dans le cas où on a besoin de lire le contenu entre deux "balises" ou bouts de texte: 'On fait deux split (comme dans ton exemple) Str = "Nous avons ceci dans le texte à découper finalement" Dim MotDeDébut As String = "ceci" Dim MotDeFin As String = "finalement" MessageBox.Show(Split(Split(Str, MotDeDébut, 2)(1), MotDeFin)(0)) 'Et nous avons le texte entre le mot de début et le mot de fin à savoir " dans le texte à découper "