I'm trying to get a specific part of a string, an id from a selected name on a listbox.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'website
Dim link As String = "http://ift.tt/2gUejEn"
Dim html As String
'name selected on listbox
Dim jogador As String = ListBox1.Text
Dim pattern As String = "player id=""(.*?)"" name=""" & jogador & """"
webc1 = New WebClient
webc1.Headers.Add("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.0; es-ES; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3")
html = webc1.DownloadString(link)
Dim match As Match = Regex.Match(html, pattern)
If match.Success Then
MsgBox(match.Groups(1).Value)
End If
End Sub
I'm not getting just the id, I get a big piece of the 'html' string. I tried to look for answer's on google, I tried other patterns but i dont get it. I know this is xml, and i probably could get it using other method more appropriate, but i find this way easier.
Aucun commentaire:
Enregistrer un commentaire