|
-
Aug 7th, 2009, 01:40 PM
#1
Thread Starter
Hyperactive Member
[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.
-
Aug 7th, 2009, 02:08 PM
#2
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
-
Aug 7th, 2009, 02:14 PM
#3
Thread Starter
Hyperactive Member
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")
Last edited by Zeuz; Aug 7th, 2009 at 02:20 PM.
-
Aug 7th, 2009, 02:19 PM
#4
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)
-
Aug 7th, 2009, 02:20 PM
#5
Re: Webclient & Regex (Catch String) (One String, no more)
Try using
Code:
Dim RX As New System.Text.RegularExpressions.Regex("(?<=<td>)\d+(?=</td>)")
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Aug 7th, 2009, 02:21 PM
#6
Re: Webclient & Regex (Catch String) (One String, no more)
 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.
Last edited by stlaural; Aug 7th, 2009 at 02:28 PM.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Aug 7th, 2009, 02:23 PM
#7
Thread Starter
Hyperactive Member
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.
-
Aug 7th, 2009, 03:28 PM
#8
Thread Starter
Hyperactive Member
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.
-
Aug 10th, 2009, 10:00 AM
#9
Re: Webclient & Regex (Catch String) (One String, no more)
Post your input, and the desired output.
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|