The img src that I need to grab is:
div id="recaptcha_image" class="width: 300px; height: 57px;" style="width: 300px; height: 57px;">
<img width="300" height="57" src="http://www.google.com/recaptcha/api/image?c=03AHJ_VuvlvMA4JvVIQvDR4C_iDbOTwOF5FUIRPGkkSImDRYAD6sY2L0IxyJSpSP1WGjWqr0MQ-dmjkiIgevFY2gkMpNWi1cQbtgUZB5QaYr_vIHv6xFzG9ydFbBWs4xiEhWoxHEFUYHZj6CCh4obyZSOd2La0nozLZw" style="display:block;">
Here is my code that grabs all the img src tags from any website. The one thing is the img src that I need isn’t listed in the returned results.
How can I correct my code to grab only this one field? Here is my working program…currently is doesn’t load a pic into the picturebox…but it does return the results in the rich text box. Thanks
Dim s As String = TextBox1.Text
Dim hw As New HtmlWeb()
Dim doc As HtmlDocument = hw.Load(s)
Dim items As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//img")
If items Is Nothing Then
MessageBox.Show("There is nothing to show you")
End If
If items IsNot Nothing Then
For Each item As HtmlNode In items
RichTextBox2.Text = RichTextBox2.Text & (item.GetAttributeValue("src", "value") & Environment.NewLine)
'PictureBox1.Load(item.GetAttributeValue("src", TextBox1.Text & "value"))
Next
Without the complete HTML it is difficult to say, but if you want the
srcfor this specificimgyou can use the following inSelectNodes(which should probably be changed toSelectSingleNode).doc.DocumentNode.SelectSingleNode("//div[@id='recaptcha_image']/img[1]").Attributes("src").ValueThe above will return the
srcString for theimgtag.