【发布时间】:2020-03-19 09:39:37
【问题描述】:
我正在尝试从网页 www.bizi.si 中抓取公司数据。它工作正常,但是当我在网站 BIZI 中更改公司时,我在 excel 中得到与先前搜索相同的结果(REPROMAT d.o.o. 和地址),但我想成为结果(CERJAK d.o.o. 和地址)。我必须关闭并打开 excel 才能提取不同的公司数据。我希望我可以在不关闭 excel 文件的情况下从不同公司抓取数据。谢谢。
子公司数据()
将 html 作为 HTMLDocument,ws 作为工作表,节点作为对象
Set ws = ThisWorkbook.Worksheets("NAROČILO")
Set html = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "https://www.bizi.si/iskanje?q=" & Application.EncodeURL(ws.Range("A1").Value), False
.send
html.body.innerHTML = .responseText
Set nodes = html.querySelectorAll("td.item")
With ws
.Range("A4").Value = nodes.Item(0).FirstChild.innerText
.Range("A5").Value = nodes.Item(1).innerText
.Range("B6").Value = nodes.Item(3).innerText
End With
.Open "GET", html.querySelector("[id$=linkCompany]").href, False
.send
html.body.innerHTML = .responseText
ws.Range("A3") = html.querySelector("#ctl00_ctl00_cphMain_cphMainCol_CompanySPLPreview1_labTitlePRS").innerText
End With
结束子
【问题讨论】:
-
我无法重现此内容。如果我更改单元格 A1 中的值,它运行得很好
-
我现在工作正常。看起来是笔记本电脑本身的问题。太多的工作。 :) 谢谢。 QHarr
-
不用担心。很高兴它解决了。
-
QHarr 我需要帮助解决同样的问题 - 他们改变了网站我现在遇到了同样的问题