Skip to main content

social-media Scenario 4 — Forum Thread — Extract Nested Comments

Written by RTILA X Engineering Team

Intermediate ~6 min
Prerequisites: social-media/1 social-media/2

What You'll Learn

Handle infinite-scroll feeds on social media

Real-World Use Case

Archiving a complete timeline

LIVE DEMO

Best practices for web scraping in 2025?

techguru42

Comment body 1 discussing the thread topic.

dom_dave

Nested reply 1 from dom_dave.

puppeteer_paul

Nested reply 2 from puppeteer_paul.

dataminer_sam

Comment body 2 discussing the thread topic.

playwright_pam

Nested reply 3 from playwright_pam.

cypress_cy

Nested reply 4 from cypress_cy.

scraper_queen

Comment body 3 discussing the thread topic.

selenium_sid

Nested reply 5 from selenium_sid.

api_amy

Nested reply 6 from api_amy.

automation_alice

Comment body 4 discussing the thread topic.

regex_ray

Nested reply 7 from regex_ray.

variable_vic

Nested reply 8 from variable_vic.

selector_sam

Comment body 5 discussing the thread topic.

loop_linda

Nested reply 9 from loop_linda.

trigger_tom

Nested reply 10 from trigger_tom.

css_crusader

Comment body 6 discussing the thread topic.

command_carl

Nested reply 11 from command_carl.

dataset_dee

Nested reply 12 from dataset_dee.

json_jess

Comment body 7 discussing the thread topic.

guest

Nested reply 13 from guest.

guest

Nested reply 14 from guest.

xpath_xavier

Comment body 8 discussing the thread topic.

guest

Nested reply 15 from guest.

guest

Nested reply 16 from guest.

EXPECTED OUTPUT

RTILA X PROJECT JSON

    {
  "name": "Extract_Forum_Thread",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/social-media/4"
    ]
  },
  "datasets": {
    "comments": {
      "item_selector": "css=.forum-comment",
      "properties": [
        {
          "name": "author",
          "type": "text",
          "selector": "css=.comment-author"
        },
        {
          "name": "time",
          "type": "text",
          "selector": "css=.comment-time"
        },
        {
          "name": "text",
          "type": "text",
          "selector": "css=.comment-text"
        },
        {
          "name": "replies",
          "type": "list",
          "selector": "css=.forum-reply",
          "properties": [
            {
              "name": "author",
              "type": "text",
              "selector": "css=.reply-author"
            },
            {
              "name": "time",
              "type": "text",
              "selector": "css=.reply-time"
            },
            {
              "name": "text",
              "type": "text",
              "selector": "css=.reply-text"
            }
          ]
        }
      ]
    }
  },
  "commands": [
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.forum-comment"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "comments"
      }
    }
  ]
}
  

Nested comment structures are represented with a list property inside the comment dataset. Each reply has its own author, timestamp, and text selectors.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 2 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?