|
-
Aug 31st, 2012, 12:20 AM
#1
Thread Starter
Addicted Member
scrape the string between the div tag
How do I scrape the string between the div tag? td_tag.InnerText is empty. There are no attributes.
*************
Dim td_tags As HtmlElementCollection = wb.Document.GetElementsByTagName("td")
For Each td_tag As HtmlElement In td_tags
If td_tag.GetAttribute("classname") = "bids bin1" Then
TextBox11.Text = TextBox11.Text & " - " & td_tag.InnerText
End If
Next
**********************
<td class="bids bin1">
<div>Buy It Now</div>
</td>
-
Aug 31st, 2012, 02:29 PM
#2
Thread Starter
Addicted Member
Re: scrape the string between the div tag
Anyone knows how to scrape this string?
-
Aug 31st, 2012, 02:47 PM
#3
Re: scrape the string between the div tag
I would use just one WebBrowser Control, go back to your original code and fix the bug in it. The outline of your code might look like:
vb.net Code:
' Collection of Rows
Dim trs As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("tr")
For Each tr As HtmlElement In trs
' Filter on itemprop="offers"
If tr.GetAttribute("itemprop") = "offers" Then
' Collection of Cells
Dim td_tags As HtmlElementCollection = tr.GetElementsByTagName("td")
For Each td_tag As HtmlElement In td_tags
' pull required data from elements of each pertinent cell
'
' e.g.
'If td_tag.GetAttribute("classname").Contains("bids") Then
' TextBox11.Text = TextBox11.Text & vbCrLf & " - " & td_tag.InnerText.Replace(vbCrLf, "")
'End If
Next ' TD
End If ' filter
Next ' TR
Note that for the bids cell, the class name changes by row, so you might want to use a part of the class name that is common to all rows, like "bids"
Also note that the InnerText of this cell may contain a line break, so you may need to replace that with "".
-
Aug 31st, 2012, 04:18 PM
#4
Lively Member
Re: scrape the string between the div tag
Could always use Regex or indices and subtrings, but it wouldn't be as flexible
-
Sep 1st, 2012, 10:56 PM
#5
Thread Starter
Addicted Member
Re: scrape the string between the div tag
Inferrd, Thank you for all you assistance. Your last solution was right on.
Tags for this Thread
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
|