Charlie
Charlie

Reputation: 31

scraping a webpage using vba

I am trying to scrap information from multiple web sites.

<div class="detailSection">
        <span>Officer/Director Detail</span>
            <span><b>Name & Address</b></span>
            <br/>
            <br/>
     <span>Title&nbsp;VD</span>
     <br/>
     <br/>
GUNN, BETTY    <span>

<div>
6922 SOUTH LAGOON DR<br/>
         PANAMA CITY BEACH, FL 32408<br/>
</div>

I am able to pull all of the information except for the name "GUNN, BETTY".

The web page is http://search.sunbiz.org/Inquiry/CorporationSearch/SearchResultDetail?inquiryType=DocumentNumber&aggregateId=domnp-763425-68d63992-2677-4bd5-9e1e-3f63ef505809&directionType=Initial&searchNameOrder=AMBASSADORBEACHOWNERSASSOCIATI%207634250&searchTerm=763425

Officer_Director_Detail2 = Doc.getElementsByClassName("detailSection")(5).getElementsByTagName("span")(2).innerText copies "Title VD".

Officer_Director_Detail3 = Doc.getElementsByClassName("detailSection")(5).getElementsByTagName("span")(3).innerText copies "6922 SOUTH LAGOON DR PANAMA CITY BEACH, FL 32408".

I have tried using "br" and "div" but neither will copy the name. HELP!!!

Upvotes: 3

Views: 237

Answers (2)

QHarr
QHarr

Reputation: 84465

Sadly you can't use XPath of a text node but can get just that string using Split in selenium using XPath. This uses selenium type library reference after installing selenium basic.

Option Explicit
Public Sub GetInfo()
    Dim d As WebDriver, arr() As String
    Set d = New ChromeDriver
    Const URL = "http://search.sunbiz.org/Inquiry/CorporationSearch/SearchResultDetail?inquiryType=DocumentNumber&aggregateId=domnp-763425-68d63992-2677-4bd5-9e1e-3f63ef505809&directionType=Initial&searchNameOrder=AMBASSADORBEACHOWNERSASSOCIATI%207634250&searchTerm=763425"
    With d
        .AddArgument "--headless"
        .Start "Chrome"
        .get URL
        Debug.Print Split(.FindElementByXPath("//*[@id='maincontent']/div[2]/div[6]").Text, Chr$(10))(5)
        .Quit
    End With
End Sub

Upvotes: 0

h2so4
h2so4

Reputation: 1577

try this code and select the fields (txt(i)) you are interested in 'BETTY GUNN, is at txt(5)

txt = Split(doc.getElementsByClassName("detailSection")(5).innerText, vbCrLf)
For i = 0 To UBound(txt)
MsgBox i & ":" & txt(i)
Next i

Upvotes: 1

Related Questions