FranciscoRo
New Member
- Joined
- Feb 27, 2023
- Messages
- 4
- Office Version
- 2021
- Platform
- Windows
1) I want to scrap the phone number which appears in this URL: https://www.idealista.com/inmueble/96599356/
The phone is 607176984.
Up to now I have been able to get the other data that I need, from that URL .
2 Using Chrome, I get this code of the URL (the lines that are related to this case)
<div class="ide-box-contact module-contact-gray contact-data-container ">
<h2 class="txt-big txt-bold mb-small">
Anunciante
</h2>
<div id="contact-phones-container" class="hidden-contact-phones no-form">
<a role="button" aria-label="contact phone" class="icon-phone hidden-contact-phones_link" href="">
<span class="hidden-contact-phones_text">Ver teléfono</span>
<span class="animation_circle">
<span class="circle"></span>
<span class="circle"></span>
<span class="circle"></span>
</span>
</a>
</div>
<div class="professional-name">
<div class="name">
Particular
</div>
<span class="particular">
<span class="icon-block"></span>
3)I have written this code in Excel VBA
Any help will be wellcome
Any help will be wellcome
The phone is 607176984.
Up to now I have been able to get the other data that I need, from that URL .
2 Using Chrome, I get this code of the URL (the lines that are related to this case)
<div class="ide-box-contact module-contact-gray contact-data-container ">
<h2 class="txt-big txt-bold mb-small">
Anunciante
</h2>
<div id="contact-phones-container" class="hidden-contact-phones no-form">
<a role="button" aria-label="contact phone" class="icon-phone hidden-contact-phones_link" href="">
<span class="hidden-contact-phones_text">Ver teléfono</span>
<span class="animation_circle">
<span class="circle"></span>
<span class="circle"></span>
<span class="circle"></span>
</span>
</a>
</div>
<div class="professional-name">
<div class="name">
Particular
</div>
<span class="particular">
<span class="icon-block"></span>
3)I have written this code in Excel VBA
Code:
EnSub detalles_de_cada_trastero()
ActiveSheet.Select
hoja_actual = ActiveSheet.Name
Application.ScreenUpdating = False
Dim XMLPage As New MSXML2.XMLHTTP60
Dim htmldoc As New MSHTML.HTMLDocument
Dim htmlim As MSHTML.IHTMLElement
Dim htmlims As MSHTML.IHTMLElementCollection
Dim url As String
url = "https://www.idealista.com/inmueble/96599356/"
XMLPage.Open "Get", url_corregida, False
XMLPage.setRequestHeader "Content-Type", "text/xml" On Error Resume Next XMLPage.send
htmldoc.body.innerHTML = XMLPage.responseText
# First: I try with this code. It doesn't work
Set htmlims = htmldoc.getElementsByClassName("hidden-contact-phones_text")
For Each htmlim In htmlims
Sheets("hoja_actual").Cells(Fila, 12).Value = htmlim.innerText
texto = htmlim.innerText ' what I get is "Ver teléfono"
Next htmlim
====================================================
# 'Second: I try with this code
Set htmlims = htmldoc.getElementsByClassName("icon-phone hidden-contact-phones_formatted-phone _mobilePhone")
For Each htmlim In htmlims '*************************The control doesn't enter in this For-Next. It jumps it
texto = htmlim.getAttribute("href")
'Sheets("hoja_actual").Cells(Fila, 12).Value = htmlim.innerText
Next htmlim
'===============================================================
# 'Third: I try this
texto = htmldoc.getElementsByClassName("icon-phone hidden-contact-phones_formatted-phone _mobilePhone") 'Gives "nothing"
texto = htmldoc.getElementsByClassName("icon-phone hidden-contact-phones_formatted-phone _mobilePhone").Item
texto = htmldoc.getElementsByClassName("icon-phone hidden-contact-phones_formatted-phone _mobilePhone").toString
'===============================================================
# 'Fourth: I try this
texto = htmldoc.getElementById("contact-phones-container")
Set htmlims = htmldoc.getElementById("contact-phones-container") 'Error!
For Each htmlim In htmlims
texto_1 = htmlim.Children(0).innerText 'sale profesonal'
texto = htmlim.getAttribute("href")
texto_2 = htmlim.Children(1).innerText
Next
Any help will be wellcome
Any help will be wellcome