Html & VB net how to download an img with a link inside a tag?

Asked

Viewed 167 times

1

After using a Webbrowser to log into a site with Vb, I want to access my site profile, and download the image of my profile

<a href="#" data-target="#profile-photo" data-toggle="modal" class="profile-photo" style="background-image: url("LINK_IMG"); display: block;"><i class="fa fa-camera"></i></a>

Grab the link from this part background-image: url("LINK_IMG");

and then automatically download. It’s Possible?

  • Good morning, you want to download your profile image?

  • 1

    Yes, that, and the link on that line has the image extension . jpg if it makes it easy...

1 answer

0

Good morning, below is an example of how to download files.

1º - Create a button in Frontend

<asp:Button ID="btnBaixarArq" runat="server" Text="Baixar Arquivo" />

2º - Refer to Namespace below. Place at the top of the page

 Imports System.Net

3º - Create the clik event call from the button

Protected Sub btnBaixarArq_Click(sender As Object, e As EventArgs) Handles btnBaixarArq.Click
    Dim client As WebClient = New WebClient

    Try

        Dim urlArquivo As String = "http://ExemploDeSite.com.br/Teste/black.gif"
        Dim caminhoArquivo As String = "D:\PastaTeste"

        client.DownloadFile(urlArquivo, caminhoArquivo)

    Catch ex As Exception
        MsgBox("Erro ao fazer Download!")
    End Try
End Sub
  • Like this, but the url I want to take from the background-image: url("LINK_IMG.jpg");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.