• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Trouble inspecting html elements of a webpage

shahin

Active Member
I've encountered such a webpage in which I can't find any way to inspect the element of it's DOM structure.

This is the link to the webpage: https://www.tradingview.com/chart/?symbol=BITSTAMP:ETHUSD

Below is the picture of specific data (marked with black color) whose html elements i'm after. Any guidance as to how I can inspect it's DOM will be highly appreciated. Thanks in advance. Btw, when I hover my mouse over the data and right click on it, I could not find any option for inspecting element.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    40.8 KB · Views: 9
When I try to get the five different titles from the bottom of that page, I can do that very easily but in case of the data I've pointed out in the above picture i can't anymore.
Code:
Sub Web_Data()
    Dim IE As New InternetExplorer, html As HTMLDocument
    Dim storage As Object, posts As Object

    With IE
        .Visible = True
        .navigate "https://www.tradingview.com/chart/?symbol=BITSTAMP:ETHUSD"
        Do While .readyState <> READYSTATE_COMPLETE: Loop
        Set html = .document
    End With

    For Each posts In html.getElementsByClassName("title")
        Row = Row + 1: Cells(Row, 1) = posts.innerText
    Next posts
    IE.Quit
End Sub

It gives me the below output:
Code:
Screener
Text Notes
Pine Editor
Strategy Tester
Trading Panel
 
... it's commercial site that sells subscription to advanced functionalities. Such as import/export watchlist etc.

What do you expect them to do? Allow back door without paying?
 
Well, It really doesn't that difficult to get items from the above mentioned site. First I printed the source code using selenium to know which class names the data I'm after lie within, then applying the usual method I could successfully scrape that.

Getting source code:

Code:
Sub Get_Page_source()
  Dim driver As New ChromeDriver, html As New HTMLDocument

  With driver
    .Get "https://www.tradingview.com/chart/?symbol=BITSTAMP:ETHUSD"
    Application.Wait Now + TimeValue("00:00:05")
    html.body.innerHTML = .ExecuteScript("return document.body.innerHTML;")
  End With

  Debug.Print html.body.innerHTML
  driver.Quit
End Sub

Here is how I could parse the "SELL" and "BUY" amount.
Code:
Sub Web_Data()
    Dim IE As New InternetExplorer, html As HTMLDocument

    With IE
        .Visible = True
        .navigate "https://www.tradingview.com/chart/?symbol=BITSTAMP:ETHUSD"
        Do While .readyState <> READYSTATE_COMPLETE: Loop
        Application.Wait Now + TimeValue("00:00:05")
        Set html = .document
    End With

    [A1] = html.getElementsByClassName("tv-trading-toolbar__value")(0).innerText
    [B1] = html.getElementsByClassName("tv-trading-toolbar__value")(2).innerText

    IE.Quit
End Sub
 
Back
Top