I know how to extract an entire page source into VB.NET, but once I do that how do I make VB.NET search the text and return a specific vlaue that is not constant?
Take this line from the page source for example:
<td id="actualPriceContent"><span id="actualPriceValue"><b class="priceLarge">$4.30</b></span>
the text is always constant but the price is not - how do I make VB.NET return the price?
Thank you for your help!
5 Replies - 450 Views - Last Post: 15 June 2012 - 07:43 AM
#1
Beginner question - how do I make VB.NET extract specific data from HT
Posted 14 June 2012 - 10:57 PM
Replies To: Beginner question - how do I make VB.NET extract specific data from HT
#2
Re: Beginner question - how do I make VB.NET extract specific data from HT
Posted 15 June 2012 - 12:01 AM
Do streamwriter to search for the text, then count it to extract out the data you need.
#3
Re: Beginner question - how do I make VB.NET extract specific data from HT
Posted 15 June 2012 - 01:05 AM
Try using Regular Expression.
#4
Re: Beginner question - how do I make VB.NET extract specific data from HT
Posted 15 June 2012 - 06:29 AM
I looked into regular expression but it seems pretty complex to write - especially for beginners like me.
How can I make the streamwriter count?
I was also suggested to use HTML DOM but cannot find a good tutorial on it - can anyone help?
Once again thanks for all the people that replied!
How can I make the streamwriter count?
I was also suggested to use HTML DOM but cannot find a good tutorial on it - can anyone help?
Once again thanks for all the people that replied!
#5
Re: Beginner question - how do I make VB.NET extract specific data from HT
Posted 15 June 2012 - 07:17 AM
This is what I did. Worked out very well, but I had to create a similar page source, let me know how it works out. I loaded the page with a webbrowser control.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each element As HtmlElement In WebBrowser1.document.All
If element.Id = "actualPriceContent" Then
MessageBox.Show(element.NextSibling.InnerText)
End If
Next
End Sub
This post has been edited by trevster344: 15 June 2012 - 07:17 AM
#6
Re: Beginner question - how do I make VB.NET extract specific data from HT
Posted 15 June 2012 - 07:43 AM
Well, regex may not be as complex as I thought. I think I created a string that will do the work:
price is displayed like this in HTML
itemprop="price">$17.95</div>
This regex returns the value 17.95:
(?<=itemprop="price">\$).*?(?=</div>)
Thoughts?
trevster344's suggestions seems interesting too... will be sure to check it out.
Thanks for the help everyone!
price is displayed like this in HTML
itemprop="price">$17.95</div>
This regex returns the value 17.95:
(?<=itemprop="price">\$).*?(?=</div>)
Thoughts?
trevster344's suggestions seems interesting too... will be sure to check it out.
Thanks for the help everyone!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|