Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor some websites continuously and perform actions regularly

What I want to do is to post my question on a forum (e.g. Stack Overflow) and have a program concentrate on it. When someone have post their answer or reply on my post, then the program will send me an email to inform me.

One way that I could think of is to perform it using PHP with file_get_contents or curl. Keep fetching the content of the website regularly, when the number of posts / reply is changed, then send an email to me. I know that way is quite stupid so I would like to know if there are any other ways to do it.

I prefer using PHP, but if there are any other programming language which can achieve that goal are also welcome.

like image 804
newhand Avatar asked Oct 02 '22 22:10

newhand


1 Answers

If the given website has an API, you can use it and create a PHP script that would fetch the required content of the given site. If it doesn't have an API, you can simply file_get_contents() the URL and check if there are changes. Directly scraping the website is generally regarded as a bad idea and hence I don't recommend it.

Once you have the script up and running, you can schedule it as a cronjob and have the script run at regular time intervals.

As for sending emails, you can use PHPMailer of SwiftMailer -- both are excellent tools to send emails from within a PHP script.

like image 68
Amal Murali Avatar answered Oct 07 '22 20:10

Amal Murali