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>
Re: scrape the string between the div tag
Anyone knows how to scrape this string?
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 "".
Re: scrape the string between the div tag
Could always use Regex or indices and subtrings, but it wouldn't be as flexible
Re: scrape the string between the div tag
Inferrd, Thank you for all you assistance. Your last solution was right on.