How Do I Grab Specific Text From a Web Page?

Hi all,

I know this kind of question has been asked many times before, like over here , but I can't seem to figure out exactly how to grab the text from a web page.

What I'm trying to do is to grab the text AAPL 123.66 <---- this is the share price and may vary, from this page on Tradingview. When I open the Web Inspector in Safari and search for the word AAPL in the code, it is easy to find within the web page. I also know that in Tradingview I should use the Execute Javascript in Front Browser action with something like the below code, to grab it (it's an example I found somewhere eon the forum).

var divElem = document.querySelector('div.section-directions-trip-distance div')
divElem.innerText 

However, I don't know how to interpret the code on the Tradingview page to figure out what code to add in the Action in KM.

I would highly appreciate if someone more knowledgable can assist please.

Thank you so much for your assistance in advance.

Hey Jaco,

Something like this I reckon:

document.querySelector("[data-symbol-short='AAPL']");

The page commandeers right-click, so you have to open the developers tools and use the select-element tool to go to the desired object.

I selected the last trade, and then backed up to the row to try to find a unique element that would be unlikely to change.

image

That's where I came up with data-symbol-short='AAPL' .

-Chris

Chris, thanks very much for the assistance. The Tradingview page I'm using looks slightly different, because I have an account and am logged in, so the specific example you have above, does not apply in my view. I was still trying to figure out how to use your example when I noticed that the actual title of the web page contains the info I need. I therefor proceeded to make us of the %SafariTitle% token to get the info I need. Thanks again for your willingness to assist.

1 Like