开发者

Visual Basic Regex but no double quotes

i'm using regex to get some information from a website, i have this code:

Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.startkabel.nl/zoeken/index.php?zoek=" & TextBox1.Text)

Dim response As System.Net.HttpWebResponse = request.GetResponse

Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

Dim startpagina As String = sr.ReadToEnd

Dim sp As New System.Text.RegularExpressions.Regex("<a href=http://games.startkabel.nl>games.startkabel.nl</a></td>")

Dim matches As MatchCollection = sp.Matches(startpagina)


For Each itemcode As Match In matches    
    ListBox1.Items.Add(itemcode.Value.Split("""").GetValue(0))    
Next

but <a href=http://games.startk开发者_如何学编程abel.nl>games.startkabel.nl</a></td> doesn't have "" so the listbox shows the whole code while I only need this part

games.startkabel.nl

i already tried to change the code to this:

"<a href=""http://games.startkabel.nl"">""games.startkabel.nl""</a></td>"

but then it doesn't show any result.

Can someone help me with this problem?

(sorry for my bad English)


Are you trying to retrieve the hyperlink URL or the hyperlink name?

itemcode.Value.Split("="c, "<"c, ">"c).GetValue(2)

will return the URL "http://games.startkabel.nl"

itemcode.Value.Split("="c, "<"c, ">"c).GetValue(3)

will return the hyperlink name "games.startkabel.nl"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜