Parsing HTML extracted from RSS to post to Discord

Hi there,

I’m really excited to learn how powerful is Make :slightly_smiling_face:

I’m trying to achieve the following scenario :
Every day a list of events is posted on this website


there is an RSS feed available here : https://monopolygo.wiki/tag/events/rss
The objectif is with these information to post a message in a discord channel like this :
image

I’ve created a scenario in Make with the Retrieve RSS Feed Items module.
I successfully get as output the description field where the HTML contains all needed information. it looks like :

//some code before....

<div class="event-container" style="flex-direction: row;margin-bottom: 1em;padding:1em;background-color: #f5f5f5;border-radius:5px;box-shadow: 0 1px 2px #b9b9b9;justify-content: space-between;align-items:center;">
  <div>
    <img alt="Mega Heist" style="max-height:50px" src="https://cdn.monopolygo.wiki/commodities/MegaHeist.png">
    <span style="font-weight:bold;">Mega Heist</span>
  </div>
  <div style="display: flex;flex-direction: column;">
    <div>
        <span class="local-date" data-date="1705561200.0">02:00AM</span> —
        <span class="local-date" data-date="1705582740.0">07:59AM EST</span>
    </div>
    <span><b>Duration:</b> 01:00:00</span>
  </div>

</div>

<div class="event-container" style="flex-direction: row;margin-bottom: 1em;padding:1em;background-color: #f5f5f5;border-radius:5px;box-shadow: 0 1px 2px #b9b9b9;justify-content: space-between;align-items:center;">
  <div>
    <img alt="Cash Grab" style="max-height:50px" src="https://cdn.monopolygo.wiki/commodities/CashGrab.png">
    <span style="font-weight:bold;">Cash Grab</span>
  </div>
  <div style="display: flex;flex-direction: column;">
    <div>
        <span class="local-date" data-date="1705572000.0">05:00AM</span> —
        <span class="local-date" data-date="1705582740.0">07:59AM EST</span>
    </div>
    <span><b>Duration:</b> 00:15:00</span>
  </div>

</div>

//some code after

I have several div with class “event-container” that I want to parse to get from each one :

  • name of the event
  • url of the image
  • start time
  • end time
  • duration

RSS feed module works fine, Discord module works fine but I’m stuck on how to format the messages

What would be the best way to do that ? :thinking:

Any help would be greatly appreciated.

Thanks in advance

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this regular expression pattern

alt="(?<name>[^"]+)"[\w\W]+?src="(?<img>https:[^"]+)"[\w\W]+?(?<start>\d+:\d+[AP]M)<\/span>[\w\W]+?(?<end>\d+:\d+[AP]M)(?: \w+)<\/span>[\w\W]+?Duration:<\/b>\s+(?<duration_hours>\d+):(?<duration_mins>\d+):\d+<\/span>

Regex test: https://regex101.com/r/6RJyzP

Important Info

  • :warning: Global match must be set to YES!

Screenshot

Output

For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.


In what way are you stuck? Please provide additional information on how you are stuck.

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Output bundles

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

@samliew

You are awesome ! This is exactly what I was looking for :astonished:

Simon Cowell Wow GIF by America's Got Talent

Here is the posted message to Discord, I just have now to format it a bit but the big part is here.

One just last thing, there are 7 events to retrieve but only 6 have been posted to Discord and I have this RuntimeError warning :

What does it means exactly ?

Thanks again @samliew :pray:

2 Likes

That means you can either aggregate to text so that you only send a single message, or you can use a sleep module to space out the messages because you cannot post so many at the same time.

3 Likes

I’m not sure how to do this.
I’v added a “Compose string” and “Text aggregator” before the “Discord” module.

but I still have 7 operation in the “Discord” output.

How ever I don’t have the warning message anymore.
Was that your suggestion @samliew ? I’m doing it right ?

Thanks in advance.

PS : I have upgraded now from the Free to Core plan, in order to avoid any limitation…

Every result (item/record) from a search module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module.

But to aggregate, you need to set the “Source Module” field correctly to the module where all the bundles are CREATED. Usually this is a Search or Iterator module, but in your case it’s the Text Parser module.

You can click the white circle to see that there are that many bundles coming out of it.

2 Likes

Thanks for you feedback @samliew :pray:

I’ve tried to set up what you sais but I’m a bit confused as it still outputing 7 bundles after the array aggregator…

here is my scenario :

the iterator module :


the array aggregator module :


it’s weird no ? :thinking:

In your aggregator, set the source module to the text parser.

3 Likes

Thank you so much @samliew it works now.

Thank U Reaction GIF by Chris Gethard

1 Like