looking for some solutions? You are welcome.

SOLVED: Web scraping in Investing.com with Excel vba


I have no knowledge of vba. Only the macro recorder is used. I need to download the data from a web page to an Excel spreadsheet and with my knowledge of vba I am not capable.

In particular, what I want to do a macro to download to Excel a data table of the page: https://www.investing.com/equities/cellnex-telecom-historical-data

This download would have to be configured in terms of time, date range and ordering.

The steps would be the following: 1.- The objective is to copy the data from the "CLNX historical data" table to an Excel spreadsheet. 2.- That download should be done by previously selecting "Monthly" in the drop-down menu by calling "Term". 3.- That the download is made by previously selecting the range of dates for the last 2 years. 4.- Finally, order the table in descending order by the column "Maximum". 5.- Once the term, the date range and the order are selected, copy the data from the "CLNX historical data" table to an Excel spreadsheet.

I have tried with the macro recorder but I am not able to configure the term, the date range or the ordering.

Could someone help me?

Thanks for your help.

The code:

Sub DataInvesting()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

IE.navigate "https://www.investing.com/equities/cellnex-telecom-historical-data"

Do Until IE.readyState = 4



IE.Document.getElementsByClassName("newInput selectBox float_lang_base_1")(0).Value = "Monthly"

IE.Visible = True

Set IE = Nothing

Set appIE = Nothing

End Sub

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: