【发布时间】:2018-10-23 19:17:28
【问题描述】:
我正在尝试从 URL 中提取最后一个页码,我想获取最大页数。
下面是我的网址
https://www.justdial.com/Upleta/Cosmetic-Wholesalers-in-Upleta-Lati-Plot
下面是我尝试的 VBA 代码,但有些地方有问题
Dim sResponse As String, html As HTMLDocument
Dim url As String
Dim N As Long
Dim X As Long
url = ActiveCell.Value
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", url, False
.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
.send
sResponse = StrConv(.responseBody, vbUnicode)
End With
Set html = New HTMLDocument
With html
.body.innerHTML = sResponse
ActiveCell.Offset(1, 0) = .getElementByClass("Jpag").innerText
ActiveCell.Offset(1, 0) = .getElementById("srchpagination").innerText
ActiveCell.Offset(0, 1).Select
End With
请大家帮帮我
【问题讨论】:
-
您面临的具体问题是什么?代码运行但结果错误,还是代码在某些时候失败?
标签: html excel vba web-scraping