|
-
Jan 26th, 2009, 07:04 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2008] Need help with: Parsing HTML
Hello.
I successfully wrote a code to retrieve a version number from a HTML page which is this code:
HTML Code:
<div class="header">Latest Version: <span class="version">6.59</span></div>
Using this code:
VB Code:
Dim src As String Dim net As New Net.WebClient() src = net.DownloadString("http://site.com") version = src.Substring(InStr(src, "Latest Version:", CompareMethod.Text) + 33, 4)
So the following code will return the version number which currently is 6.59 which is what I'm after.
But then i remembered that releases are done as following: 6.59, 6.59b, 6.59c, 6.60, 6.60b etc.
So when the b version of 6.59 is released the parser will still return 6.59. So how can i make this code better?
Thank you
Last edited by n00b scripter; Jan 26th, 2009 at 07:14 PM.
-
Jan 26th, 2009, 07:12 PM
#2
Fanatic Member
Re: [2008] Need help with: Parsing HTML
Try to change your code to get it to get the contents between
<span class="version">****</span>
then it would be easier to get the correct data, else you would have to change the current code so that it gets 5 chars instead of 4
(InStr(src, "Latest Version:", CompareMethod.Text) + 33, 4))
but that would just mess up depending on which type of version you release.
Could be version 6.35.4.5 which is alot more than 5 chars
-
Jan 26th, 2009, 07:14 PM
#3
Thread Starter
Addicted Member
Re: [2008] Need help with: Parsing HTML
 Originally Posted by Zeelia
Try to change your code to get it to get the contents between
<span class="version">****</span>
then it would be easier to get the correct data, else you would have to change the current code so that it gets 5 chars instead of 4
(InStr(src, "Latest Version:", CompareMethod.Text) + 33, 4))
but that would just mess up depending on which type of version you release.
Could be version 6.35.4.5 which is alot more than 5 chars
Well yeh I've understood that that's what I need to do. But I don't really know how to do it.
-
Jan 27th, 2009, 05:08 AM
#4
Thread Starter
Addicted Member
Re: [2008] Need help with: Parsing HTML
-
Jan 27th, 2009, 06:57 AM
#5
Re: [2008] Need help with: Parsing HTML
Hope this helps
Code:
Dim sPattern As String = "<span .*?>(.*?)</span>"
Dim src As String
Dim net As New Net.WebClient()
src = net.DownloadString("http://site.com")
MessageBox.Show(System.Text.RegularExpressions.Regex.Matches(src, sPattern).Item(0).Groups(0).Value)
Please mark you thread resolved using the Thread Tools as shown
-
Jan 27th, 2009, 06:59 AM
#6
Hyperactive Member
Re: [2008] Need help with: Parsing HTML
vb Code:
output = RegularExpressions.Regex.Replace(source, "<span[^>]*>((?:(?!<span[^>]*>).)*?)</span>", "[\1]", RegexOptions.IgnoreCase)
-
Jan 27th, 2009, 07:01 AM
#7
Hyperactive Member
Re: [2008] Need help with: Parsing HTML
danasegarane i m late in responding any way "n00b scripter"
use any of the solution given
-
Jan 27th, 2009, 07:12 AM
#8
Re: [2008] Need help with: Parsing HTML
It is their wish
Please mark you thread resolved using the Thread Tools as shown
-
Jan 27th, 2009, 02:26 PM
#9
Thread Starter
Addicted Member
Re: [2008] Need help with: Parsing HTML
 Originally Posted by danasegarane
Hope this helps
Code:
Dim sPattern As String = "<span .*?>(.*?)</span>"
Dim src As String
Dim net As New Net.WebClient()
src = net.DownloadString("http://site.com")
MessageBox.Show(System.Text.RegularExpressions.Regex.Matches(src, sPattern).Item(0).Groups(0).Value)
Worked perfect with Groups(1) Took me a few minutes to figure it out but I managed to find it 
Thank you
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
|