如何获取指定元素的所有信息?

时间:2019-06-14 16:39:20

标签: excel vba web-scraping

我正在尝试创建一个宏,这将使我的工作更加轻松,到目前为止,我只从每个div的第一行中获取数据。

我正在学习编程。但这是我到目前为止完成的循环


<details open="open">
    <summary tabindex="0" class="details-intd" id="wb-2" role="button" aria-expanded="true">
        Ticket Details
        <span class="rightP">
            <strong>ref: </strong>
            <span class="text-danger">#10</span> 
            <span class="mrgnlg">
                <a class="bttm-0" href="editd.asp?id=9">Edit</a>
            </span>
        </span>
    </summary>       
    <div class="col-3">
        <strong>Requester:</strong> 
        <span class="tp">NAME</span><br>
        <strong>Client:</strong> <br>
        <span class="tp">NAME</span> 
        (PHONE#)<br> 
        DESCRIPTION<br>
       <strong>POSITION:</strong> <br>
       <span class="tp">NAME</span> 
       (PHONE#)
    </div>    
   <!-- Another 3 div class="col-3" like the above with the same classes and tags with different information ofcourse-->
</details>

这是一个内部网站,所以我不能提供太多。

        For Each topic In IE.Document.getElementsByClassName("col-3")
            With topic.getElementsByTagName("strong")
                If .Length Then row = row + 1: Cells(row, 1) = .Item(0).innerText
            End With

            With topic.getElementsByClassName("tp")
                If .Length Then Cells(row, 2) = .Item(0).innerText
            End With
        Next topic

因此,目前我仅获得标签<div class="col-3">和类<strong>的每个"tp"的第一行

0 个答案:

没有答案