To download a html file with all the images, buttoms, etc linked to it, to C:\ in my computer

FranciscoRo

New Member
Joined
Feb 27, 2023
Messages
4
Office Version
  1. 2021
Platform
  1. Windows
In order to download a PDF file to my computer, I use this code:

Sub descargar_archivo()

‘Descargo un archivo PDF y lo guardo en mi ordenador.

Dim FileUrl As String

Dim objXmlHttpReq As Object

Dim objStream As Object


FileUrl = "https://sede.agenciatributaria.gob.es/static_files/Sede/Tema/Destacados/Mod_repre/repre_2_es_es.pdf"

Set objXmlHttpReq = CreateObject("Microsoft.XMLHTTP")

objXmlHttpReq.Open "GET", FileUrl, False, "username", "password"

objXmlHttpReq.send


If objXmlHttpReq.Status = 200 Then

Set objStream = CreateObject("ADODB.Stream")

objStream.Open

objStream.Type = 1

objStream.write objXmlHttpReq.responseBody

objStream.SaveToFile ThisWorkbook.Path & "\" & "file.pdf", 2

objStream.SaveToFile ThisWorkbook.Path, 2

objStream.Close

End If

End Sub

The previous code is useful for downloading a PDF file. Nevertheless, what I want to do now is to download a html file with all the images, buttoms, etc linked to it. I don´t get it . In some blogs some developers say that it’s posible to do it using Phyton or Selenium, but I don´t know how to use these aplications. What I know is Excel VBA. Any help will be wellcome.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi FranciscoRo, welcome to the board.

Please, if you post code, place it between code tags: Click the little VBA icon at the top of yur post window. Then paste your code in between. You will get better help that way.

What I don't understand is what you mean with downloading a html file. Do you want to download the page code? A html file does not have any images, buttons etc. Just code telling the browser how to set up the page and where to place images, the location of these images, etc.

The html for a page can be seen by right clicking on a page and selecting 'View source code'
For instance the code for this page starts like:
<!DOCTYPE html>
<html id="XF" lang="en-US" dir="LTR"
data-app="public"
data-template="thread_view_type_question"
data-container-key="node-10"
data-content-key="thread-1231023"
data-logged-in="true"
data-cookie-prefix="xf_"
data-csrf="1677944336,5d9951a6c0eef1e81788a8a50eb71017"
class="has-no-js template-thread_view_type_question"
>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>To download a html file with all the images, buttoms, etc linked to it, to C:\ in my computer | MrExcel Message Board</title>
<link rel="manifest" href="/board/webmanifest.php">
<meta name="theme-color" content="#507455" />
<meta name="apple-mobile-web-app-title" content="MrExcel">
<link rel="apple-touch-icon" href="/board/styles/mrexcel/mrexcel-logo-192x192.png">
 
Upvote 0
Thank you for your answer,
What I mean is this:
This site is dedicated to real estate (houses for sale, etc...): https://www.idealista.com/
I am trying to research the market. For getting my data, I do this:

first step
Then, I capture the data of all the apartments and copy in my worksheet

Second step
When I select the first apartment of the list, the site drives me to this URL
https://www.idealista.com/inmueble/98924120/

There I can see a lot of aditional information: photos, comentaries, etc...

Let's now suppose that the apartament is sold tomorrow. In that moment the apartment disappear fron the site. Today I have captured already some data of this apartment (what appears in the first screen), but not all (what appears in the second).

For this reason I would like to keep in my computer that http file ( ) with all the images, etc... linked to it, so that, when this item has disappeared from the site, I still can have this infomation.
 
Upvote 0
This is called web scraping. See these links on how you can do this.


 
Upvote 0
This is called web scraping. See these links on how you can do this.


Thank you very much
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top