1)我要删除此URL中出现的电话号码:https://www.idealista.com/inmueble/96599356/电话是607176984。到目前为止,我已经能够从该URL获得我需要的其他数据。
2)使用Chrome,我得到了URL的代码(与本例相关的行)
<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)我用Excel VBA编写了此代码
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/"
XML页面。打开“Get”,url_corregida,False
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
2条答案
按热度按时间9njqaruj1#
我的经验是可怕的这种方法..成像300产品的价格和可用性,它做了大约2.5小时。正如我建议几年前..最强大的方式来做到这一点是通过python。
但这里有一个例子
末端子组件
cngwdvgl2#
谢谢,但我得到的是一个错误,我解释如下
末端子组件