Send stock prices update to Slack with Make and ScrapingBee
It is unlikely that you will always be on top of your investments if you do not study your stock's price movements. The good news is that there are plenty of online resources available to you that allow you to monitor the financial health of a company whose shares you own, and to evaluate the stock's performance.
Yahoo Finance supplies an up-to-date news feed of financial news from some of the most trusted sources online, as well as offering a comprehensive look at stocks and funds.
ScrapingBee is a really simple API that allows you to extract HTML from every website in one single API call. With ScrapingBee, we can get structured data from any public web page.
Paired with Make (formerly Integromat), we will build a no-code workflow to perform any number of actions with the scraped data.
In this article you will learn to:
- scrape the price of a stock from Yahoo Finance
- send the data to a slack channel
Get your ScrapingBee API Key
Create a new Make Scenario
To get started, create a new Make (formerly Integromat) account or log into your existing account:
From the account homepage, create a new scenario. A Make scenario is comprised of a series of modules that indicate how data should be transferred and transformed between apps/services:
Select the app that will trigger your scenario. Click the first “+” sign and select ScrapingBee:
Now choose one of the modules from the list. From the list of actions, select “Make an API call”:
Next, you will need to create a connection or select one of your previously configured connections for the module.
Create a ScrapingBee connection
Make uses connections to connect to different services that require authentication. For example, to perform a scrape, we need to connect to ScrapingBee using our API key:
To add a connection, click on “Add” and then enter your ScrapingBee API key gotten from the ScrapingBee dashboard:
Once the connection is set up, we will now configure the action.
First, set the method to
GET. This is the default method and is what browsers use to display pages. POST is used to submit forms, but we have no need for that here.
Next, pick any stock page from Yahoo Finance. For this tutorial, we will use Tesla, and the URL for that is https://finance.yahoo.com/quote/TSLA:
Check the box “Show advanced settings”. This is where we enter the data extraction rules that allow ScrapingBee to return the data in a nicely formatted way.
Scroll to “Extract Rules (JSON)” and enter the following:
"name" : "#quote-header-info h1.D\\(ib\\).Fz\\(18px\\)",
"price" : "#quote-header-info [data-field=\"regularMarketPrice\"]",
"change" : "#quote-header-info [data-field=\"regularMarketChange\"]",
"change-percent" : "#quote-header-info [data-field=\"regularMarketChangePercent\"]",
Extraction rules can be quite complex for those not familiar with CSS. You may be interested in reading the documentation for more details about how it works.
Optionally, you should mark “Render JS” as No. This is not a feature required for this scraping job and costs extra credits.
Test the action
Now we need to check that the automation is running:
You can now test run the scrape job using the “Run Once” button at the bottom of the page. You can also use this to test your integration while working on it:
Next, we need to configure the Slack module.
Configure Slack Module
Just like with the ScrapingBee integration, we need to add a connection. This will redirect you to Slack. For the purpose of this tutorial, it does not really matter if the connection is as a bot or a user.
Next, we click the “
+” sign and add a Slack module. From the list of actions, select “Create a message”:
Select the channel ID or name you want to send the message to. In my workspace, I have created a channel called
#stock-alerts and I selected that using the “Select from List” option:
The text field is the structure of the message that will be created and sent to the Slack channel. I set it up as shown in the screenshot below, but you can structure it however you want:
Save and run the integration again. The message should be sent to the slack channel:
You can specify when and how frequently an activated scenario runs. To do so, go to the scenario detail page and locate the Schedule tab under the Options tab. From there, choose Scheduling:
To make this run every day, click the clock icon overlaying the ScrapingBee module and change the Run Scenario to Every day. Also, set the time when it should run.
Finally, turn on Scheduling for the scenario. Without turning it on, the scenario will not be run automatically regardless of the scheduling settings.
There you go. Now that you know how to study your stock's price movements from any website resource, staying on top of your investments is easy.
You might also like:
How to put scraped website data into Google Sheets
Learn how to store scraped content on Google sheet by using ScrapingBee and Make (formerly Integromat)
No-code competitor monitoring with ScrapingBee and Integromat
Competitor analysis is a vital task in big or small companies. It allows you to confirm market needs by looking at what competitors are offering.This article shows you step by step how you can set up Integromat and Scrapingbee to do it!