Pulling historical stock data

I am trying to pull the historical data from yahoo finance.
I am getting an unmatched selector using the html extract node.
I guess my html-fu isnt as good as it once was.

Im looking at the chrome console.
Its in a div, section, class called “smartphonePx”
I literally pulled it from the console, and nothing that I select seems to be correct.

I then want to compare todays price verses yesterday, 7 days, and 30 days.
Then I can get into making a dashboard out of it.

Information on your n8n setup

  • n8n version: current…
  • **Database you’re using (default: SQLite) SQLite
  • **Running n8n with the execution process [own(default), main] ??
  • **Running n8n via NPM

Hey @Gohaun,

Welcome to the community :rocket:

Can you share what you currently have that isn’t working or the url you are using and what value you are trying to get.

Im trying to pull the date, the close for the current month.

Hey @Gohaun,

Give this a bash.

How can I find this CSS selector for other pages?
Is there something that will help me find this info later and for other pages?

Edit: this did work the way i was expecting.

Hey @Gohaun,

So what I do is in the browser press F12 to open the dev tools, Go to Elements and there is a little arrow icon.

image

When you press this you can select data on a page and it will highlight it so you can see if you are selecting the correct thing.

Once selected you will see it highlighted in the HTML in the dev window and you can right click on it and do Copy > Selector.

image

Once you have this back in n8n add it to your HTML extract, Now sometimes like with this example the selector isn’t quite right and will need tweaking but most of the time you are good to go.

So as an example what I do to make sure it is right is delete everything apart from the first item and test it then add in the other parts until I what breaks it and I keep removing the bits not needed until I have it nailed.

We start with…

#post_5 > div > div.topic-body.clearfix > div.regular.contents > div > p

Our first run is just #post_5 then #post_5 > div then #post_5 > div > div.topic-body.clearfix and because it doesn’t work we delete the div.topic-body.clearfix and we repeat this process until it is just #post_5 > div > p

Now there are other ways to work out the path by reading the HTML but I find this is the process that works for me and maybe it will help give you some inspiration for your next page :slight_smile:

Man do I have some holes to fill here. Thanks, now onto the logic that I want to build in.

So I would want this to be done at a certain time each day.
So would I then just add the interval node before the http request and have it start that process at that set time each day?

Edit: I added it before the http request. Then set the time to 10 seconds, activated it. I dont see anything requesting for the data again.
Did I misunderstand what the interval node is for?

Edit2: I see it in the execution list. Would be nice to see a checkmark or something visual on the cron/interval/time node to let me know that is running.

Hey @Gohaun,

The workflows run in the background once activated which is why they are only visible in the execution log.

Normally if a workflow is active you would see it on the top right where the toggle is, I have a feeling that showing the node is currently running for active workflows might slow down the interface but I can add this to our internal feature list.

I dont want to slow down the interface, as I have seen some users are doing 100’s of workflows.
Some way to signal that something is currently running? But I also dont want to get into a “notification overload” for those that are using 100’s of workflows.

Not sure where the best place would be for that in the interface. I ahve also looked around for dashboards, and maybe that is the answer, is that I need a dashboard that tells me that stuff, without adding that info to the workflow page.

I just havnet gotten to the dashboard part of it yet.

A custom dashboard may be a good solution, the execution log will show running workflows but if you use a database like Postgres you could do almost anything you wanted.

That is what I was looking for. So I could just have a section that shows the last “n” from the execution log with the time stamp.
Now databases are not my friend.
Another thing to add to the list of things to try and figure out.
Thanks

1 Like