我正试图从网站上删除地址和电话号码。网页的HTML如下所示:
<p class="profileText">
<span id="ctl00_PageWrapper_ContentAndSidebar_ContentPlaceHolder1_TextContent_lblExhibitorDetails" class="editorLabel">Checkout.com<br>32 Wigmore Street<br>London<br>W1U 2RP<br>Tel. 0207 323 3888<br></span>
</p>
&#13;
使用此代码:
Sub Demo()
Dim URL As String
Dim ieDoc As Object
Dim cel As Range
For Each cel In Range("G2", Range("G" & Rows.Count).End(xlUp))
URL = cel.Value
With CreateObject("InternetExplorer.Application")
.Visible = False
.Navigate URL
Do Until .ReadyState = 4: DoEvents: Loop
Set ieDoc = .Document
cel.Offset(, 1).Value = ieDoc.getElementsByClassName("profileText")(0).getElementsByTagName("span")(0).innerText
.Quit
End With
Next cel
End Sub
但我没有快乐。有人可以帮我吗?
答案 0 :(得分:2)
如果没有实际的网址,很难为您提供任何解决方案。但是,试一试:
function DeleteRow() { //this function delete selected rows from table
$('input[type=checkbox]').each(function () {
if ($(this).prop('checked')) {
$(this).closest('tr').remove();
}
});
$(".btn").css("background-color", "#ff0000");
}
参考添加到库:
Sub Demo()
Dim IE As New InternetExplorer
Dim ieDoc As HTMLDocument, cel As Range
For Each cel In Range("G2", Range("G" & Rows.Count).End(xlUp))
With IE
.Visible = False
.navigate cel
Do Until .readyState = 4: DoEvents: Loop
Set ieDoc = .document
r = r + 1: Cells(r, 2) = ieDoc.getElementsByClassName("editorLabel")(0).innerText
End With
Next cel
IE.Quit
End Sub
当我有结果时,你怎么会遇到任何错误。这是一个测试人员:
1. Microsoft Internet Controls
2. Microsoft Html Object Library