Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ilona's avatar
Level 1

Should I used Laravel Websocket for Live Scraping a Website?

Let me tell you the details. I want to scrap a website in Laravel and display the results in webpage. I actually need the results in two specific times per weekdays. Which is

  1. 7:00AM
  2. 1:35PM (only on weekdays) So I created a command to scrap the website and saved the results to database.

Here's how I setup in Kernel.php

`

$schedule->command('my:command')

        ->timezone('Asia/Yangon')

        ->weekDays()

        ->dailyAt('7:00');

    $schedule->command('my:command')

        ->timezone('Asia/Yangon')

        ->weekDays()

        ->dailyAt('13:35');`

Note: Please let me know if I make something wrong I'm not good at this. That looks pretty simple right? But the thing is even though I only need the results at twice a day, I still need to display the results as live in my website in other times. So here's how I planned.

  1. Create a Websocket Service
  2. Let the client connected
  3. Once the client is connected, the websocket server do web scraping on itself and return the results to the client. So the client can get the live results.

But I'm not familiar with Websocket and I don't know is that a good approach for my problem. Please guide me the progress if possible and let me know is that a good solution or not.

0 likes
1 reply
Ilona's avatar
Level 1

I think the socket server itself might need to do both scraping and fetching data from the database. However the live scraping was supposed to updated in every 30 second so I don't want to keep fetching the data unless is about time to fetch (like current time is over 7:00AM && Over 13:35) Also I only want to fetch the data from our database only if the results are not fetched it yet. So in this case I'm thinking to use client side storages like session storage , once the client is connected with the socket server it will send the credentials from the storage which is being fetched or not, so the progress can be skip

Please or to participate in this conversation.