user1757913
user1757913

Reputation: 53

vb.net split help required

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!

Upvotes: 0

Views: 95

Answers (3)

famf
famf

Reputation: 2233

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

Upvotes: 1

Jani Hyyti&#228;inen
Jani Hyyti&#228;inen

Reputation: 5407

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.

Upvotes: 0

Hamish Smith
Hamish Smith

Reputation: 8181

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

Upvotes: 0

Related Questions