[RESOLVED] Webclient & Regex (Catch String) (One String, no more)
Hello all. I'm here again asking stupid questions.
I don't have really get this but i ask again but i try explain all better.
Here is a website link and i want catch string from here.
Look page's source code and find first what starts <td> someword </td>
I use this code for catch word from page.
Visual Basic Express 2008 Code:
Imports System.Text.RegularExpressions.Regex
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim WClient As New Net.WebClient
Dim WSearch As String
Dim RX As New System.Text.RegularExpressions.Regex("(?<=<td>).+?(?=</td>)")
WSearch = WClient.DownloadString("http://itemdb-rs.runescape.com/results.ws?query=Tarromin+seed&price=all&members=")
MsgBox(RX.Match(WSearch).Value)
End Sub
End Class
First td is this:
PHP Code:
<td><img src="http://itemdb-rs.runescape.com/2717_obj_sprite.gif?id=5293" alt="Tarromin seed"></td>
So it says me:
PHP Code:
<img src="http://itemdb-rs.runescape.com/2717_obj_sprite.gif?id=5293" alt="Tarromin seed">
Why it can not say market price word "19"
I want it to say item price.
Under this what it says me is this.
PHP Code:
<td><img src="http://itemdb-rs.runescape.com/2717_obj_sprite.gif?id=5293" alt="Tarromin seed"></td>
<td><a href="http://itemdb-rs.runescape.com/Tarromin_seed/viewitem.ws?obj=5293"> Tarromin seed</a></td>
<td>19</td>
Why it cant say this FROM here?
Can someone help me.
Thank you for answers.
Re: Webclient & Regex (Catch String) (One String, no more)
If not sure if I understand fully what you want, but I think it may be this...?
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim WClient As New Net.WebClient
Dim WSearch As String
WSearch = WClient.DownloadString("http://itemdb-rs.runescape.com/results.ws?query=Tarromin+seed&price=all&members=")
For Each m As System.Text.RegularExpressions.Match In System.Text.RegularExpressions.Regex.Matches(WSearch, "(?<=<td>).+?(?=</td>)")
MessageBox.Show(m.Value)
Next
End Sub
Re: Webclient & Regex (Catch String) (One String, no more)
Actually but i dont want it say more than 3st of your code.
Only word "19" first and no more.
<td>19</td> <=====
Hmm maybe if i tell what i want actually you may understand.
Go to this address: http://itemdb-rs.runescape.com/resul...e=all&members=
I want application pickup word 19 after tarromin seed text.
When they update website and you press button again 19 is another what they put there.
Msgbox("Current Price")
Re: Webclient & Regex (Catch String) (One String, no more)
You only want the "19"?
vb.net Code:
Dim WClient As New Net.WebClient
Dim WSearch As String
Dim RX As New System.Text.RegularExpressions.Regex("(?<=<td>)\d+?(?=</td>)")
WSearch = WClient.DownloadString("http://itemdb-rs.runescape.com/results.ws?query=Tarromin+seed&price=all&members=")
MessageBox.Show(RX.Match(WSearch).Value)
Re: Webclient & Regex (Catch String) (One String, no more)
Try using
Code:
Dim RX As New System.Text.RegularExpressions.Regex("(?<=<td>)\d+(?=</td>)")
Re: Webclient & Regex (Catch String) (One String, no more)
Quote:
Originally Posted by
Zeuz
Actually but i dont want it say more than 3st of your code.
Only word "19" first and no more.
<td>19</td> <=====
With the example that you have given us, if you really only want the "<td>19</td>" you should use a regular expression like that : "(?<=<td>)\d+?(?=</td>)"
The "\d" means that you are looking only for digits while the "." means that you are looking for ANY character. If the text between the <td> and </td> tags that you are looking for is always in an Integer format then this regex, also suggested by wild bill in the previous post will do the job, but if the format varies then your regular expression will need some changes.
Have a look at the links in my signature it might help you build a proper RegEx for your needs.
Re: Webclient & Regex (Catch String) (One String, no more)
What the .... Guys. It didn't first worked, now it works.
Thank you guys.
So much for all.
Re: Webclient & Regex (Catch String) (One String, no more)
Soz multi if this comes as multi message.
But is here any way to make it show some line like this 19 was.
Show BY line.
Re: Webclient & Regex (Catch String) (One String, no more)
Post your input, and the desired output.