|
-
Aug 29th, 2012, 03:14 PM
#1
Thread Starter
Addicted Member
HtmlElement In a_tags is not staying within if condition
I'm trying to scrape using the code below but it is not doing what I intend it to do. I want to scrape the inner text of the tag "a" when the attribute itemprop = "name". The result is correct but it scraped it twice.
The For Each a_tag As HtmlElement In a_tags is not staying within the itemprop="offers" condition.
******************
<tr itemtype="http://schema.org/Offer" itemscope="" itemprop="offers">
<a itemprop="name" title="2 Sets of Cross Country Asics Spikes with Handles!" class="vip" href="http://www.ebay.com/itm/2-Sets-of-Cross-Country-Asics-Spikes-with-Handles-/140838036468?pt=LH_DefaultDomain_0&hash=item20ca99e3f4">2 Sets of Cross Country Asics Spikes with Handles!</a>
</tr>
<tr itemtype="http://schema.org/Offer" itemscope="" itemprop="offers">
<a itemprop="name" title="2 Sets of Cross Country Asics Spikes with Handles!" class="vip" href="http://www.ebay.com/itm/2-Sets-of-Cross-Country-Asics-Spikes-with-Handles-/140838036468?pt=LH_DefaultDomain_0&hash=item20ca99e3f4">#2 - 2 Sets of Cross Country Asics Spikes with Handles!</a>
</tr>
*****************************
Dim trs As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("tr")
For Each tr As HtmlElement In trs
If tr.GetAttribute("itemprop") = "offers" Then
Dim a_tags As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
For Each a_tag As HtmlElement In a_tags
If a_tag.GetAttribute("itemprop") = "name" Then
textbox1.text = textbox1.text & vbcrlf & a_tag.InnerText)
End If
Next
End If
Next
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
|