0

im currently trying to grab an avatar from an html web source, probllem is theres several img sources and containers that have the same name, heres the current part i need

</div>

<div class="content no_margin">

    <img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />
    <br />
    <a class="link" href="http://sharefa.st/user/donkey">Uploads</a><br />
    <a class="link" href="http://sharefa.st/user/donkey/favorites">Favorites</a><br />

</div>
        </div>       

        <div id="content" class="left">
            <div class="header">

    Uploads

</div>

<div class="content no_margin">

        <div class="profile_box">

        <div class="profile_info">

Now the part i need to grab is:

 <img src="http://www.gravatar.com/avatar/4787d9302360d807f3e6f94125f7754c?&d=mm&r=g&s=250" /><br />

this image, Any help and id be grateful!

user1757913
  • 53
  • 1
  • 11

3 Answers3

1

try:

    Dim wb As New WebBrowser
    wb.Navigate("")
    Do While wb.ReadyState <> WebBrowserReadyState.Complete
        Application.DoEvents()

    Loop
    wb.DocumentText = HtmlString 'Your Html
    For Each img As HtmlElement In wb.Document.GetElementsByTagName("img")
        If InStr(img.GetAttribute("src"), "avatar") Then
            MsgBox(img.GetAttribute("src"))
        End If
    Next
famf
  • 2,225
  • 19
  • 17
0

You appear to be attempting to parse HTML 'by hand'. Please don't.

http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html

see this question for some alternatives How do you parse an HTML in vb.net

Community
  • 1
  • 1
Hamish Smith
  • 8,153
  • 1
  • 34
  • 48
0

Use regular expression to find what you're looking for: http://msdn.microsoft.com/en-us/library/twcw2f1c.aspx

The example code demonstrates pretty much your scenario.

Jani Hyytiäinen
  • 5,293
  • 36
  • 45