I have a web scraper that runs great, I can pass it a list of domain names, and it will scrape each site to see which sites are missing SEO. I realize there are tools for this (like Screaming Frog) but I am trying to create a PHP script to do this for me and write the results to a Google Sheet.
I've got a Google Sheet with a list of 300 sites. My script pulls from this Google Sheet like so:
$domain_batch = getBatchOfFive(1,5);
This returns 5 of the sites from the Google Sheet, and then I take the returned array and pass it to a function that scrapes each site like so:
foreach ($domain_batch as $site){
$seo = getAllPagesSEO($site);
//then logic to add the results to a spreadsheet
}
Then when I run it again, I change that to:
$domain_batch = getBatchOfFive(6,10);
And so on until I get through all of the sites in the Google Sheet.
How I run this script, is I just pull up the script in my browser:
https://example.com/seo-scraper.php
The problem is I can only scrape about 5 sites at a time before the script times out. I'm wondering if it would be possible to run this script incrementally somehow.
Is there any way I could programmatically create something that would run the script for the first 5 sites, and once the script finishes running, it would automatically run the script again with another 5 sites, and continue doing this process until all of the sites are run through the script?
That way I don't have to go into seo-scraper.php after each run and change the values here:
$domain_batch = getBatchOfFive(6,10);
I'm thinking this might not be possible, but I'm looking for any ideas!