Send stock prices update to Slack with Make and ScrapingBee

14 March 2022 | 4 min read

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.

cover image

Getting Started

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:

  1. scrape the price of a stock from Yahoo Finance
  2. send the data to a slack channel

Get your ScrapingBee API Key

In order to add a connection, you’d need your ScrapingBee API key. To get your API Key, you just need to create an account  here . Your API key can be gotten from the ScrapingBee dashboard :

Screenshot 2022-03-04 at 09.42.37.png

Create a new Make Scenario

To get started, create a new Make (formerly Integromat) account or log into your existing account:

Screenshot 2022-03-04 at 09.59.01.png

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:

Screenshot 2022-03-04 at 10.04.32.png

Select the app that will trigger your scenario. Click the first “+” sign and select ScrapingBee:

Screenshot 2022-03-04 at 15.42.03.png

Now choose one of the modules from the list. From the list of actions, select “Make an API call”:

Screenshot 2022-03-04 at 15.48.41.png

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:

5. Add new connection.png

To add a connection, click on “Add” and then enter your ScrapingBee API key gotten from the ScrapingBee dashboard :

Screenshot 2022-03-04 at 15.52.27.png

Once the connection is set up, we will now configure the action.

Configure 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 :

20. Yahoo finance URL.png

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\"]",
}

21. Yahoo finance extraction rules.png

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.

9. (Optional) Turn off JS rendering.png

Test the action

Now we need to check that the automation is running:

Screenshot 2022-03-04 at 16.00.29.png

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:

22. scrape test run.png

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”:

23. Add slack module.png

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:

24. Configure slack channel.png

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:

25. Slack message setup.png

Save and run the integration again. The message should be sent to the slack channel:

26. Slack stock message.png

Schedule Scenario

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:

Screenshot 2022-03-04 at 16.03.01.png

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.

Screenshot 2022-03-04 at 17.38.27.png

Finally, turn on Scheduling for the scenario. Without turning it on, the scenario will not be run automatically regardless of the scheduling settings.

28. Turn on scheduling.png

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.

image description
Juliet Edjere

Juliet is an automation expert with vast experience working with no code tools.