Irzan Gustanto
Irzan Gustanto

Reputation: 1

Why do I always get empty value

I'm trying to make a module to webscrape data for this site to excel but I keep geting empty value can anyone help me

so here's my module

Sub StockRetrieve()

    Dim bot As New WebDriver
    
    bot.Get "https://stockbit.com/#/symbol/NELY/financials"
    
    bot.FindElementByXPath("//*[@id='content-box']/div[3]/div[2]/div[1]/div[3]/select").Click
    bot.FindElementByXPath("//option[@value='bs']").Click
    asset2020 = bot.FindElementByXPath("//table[contains(@class,'fin-table')]/tbody/tr[23]/td[2]").TextAsNumber
    Sheets(1).Range("B2").Value = asset2020

    Stop
End Sub

Upvotes: 0

Views: 136

Answers (1)

Nicholas Hunter
Nicholas Hunter

Reputation: 1845

It may be that one or more of the paths is wrong. Step through the code and verify the value of elem at every step. If everything looks good, then are you sure that the value you're trying to read is not empty?

Sub StockRetrieve()

    Dim bot As New WebDriver
    Dim elem as Variant

    bot.Get "https://stockbit.com/#/symbol/NELY/financials"

    elem = bot.FindElementByXPath("//*[@id='content-box']/div[3]/div[2]/div[1]/div[3]/select")
    elem.Click 

    elem = bot.FindElementByXPath("//option[@value='bs']")
    elem.Click 

    elem = bot.FindElementByXPath("//table[contains(@class,'fin-table')]/tbody/tr[23]/td[2]")

    asset2020 = elem.TextAsNumber 
    Sheets(1).Range("B2").Value = asset2020

End Sub

Upvotes: 1

Related Questions