split task to 3 files.
- file for retrieving page list and as your main script (to put on crontab) (main.php)
- for parsing the actual page. (parse.php)
- some shell script to process your 2nd script.
Then, in your 1st file, do something like this:
<?php
$pagelist = get_page_list();//this will retrieve page list using CURL and save each page to some, let's say pagelist.txt and return this absolute path.
exec("/path/to/php /your/3rdscript.sh < $pagelist");
?>
And here's your 3rd file:
#!/bin/bash
while read line
do
/path/to/php /path/to/your/2ndscript.php -f $line &
done
Please note that on 3rd script (the shell script) I use & (ampersand). This will tell the shell to put that particular process into background process.
On your 2nd script, you can use something like this:
<?php
$pageurl = $argv[2];
//do your curl process to fetch page $pageurl here
Using step above, you can speed up by fetching several pages at once.