我是 PHP 和 MySQL 新手。不知道是否可行
这是我的 MySQL 表
Id url 1 http://www.urla.com 2 http://www.urlb.com 3 http://www.urlc.com 4 http://www.urld.com 5 http://www.urle.com 6 http://www.urlf.com 7 http://www.urlg.com 8 http://www.urlh.com 9 http://www.urli.com 10 http://www.urlj.com
Here is my php code
$getURL_List="select url from my_table";
$statement = $mysqli->prepare($getURL_List);
//execute query
$statement->execute();
//store result
$statement->store_result();
//bind results variables
$statement->bind_result($url);
//count the result
$countRows = $statement->num_rows;
while ($statement->fetch()) {
Questions:
============
How do I get the first 5 url returned from my query and open them in the browser
1 http://www.urla.com - go to this URL (open it in the browser)
2 http://www.urlb.com - go to this URL (open it in the browser)
3 http://www.urlc.com - go to this URL (open it in the browser)
4 http://www.urld.com - go to this URL (open it in the browser)
5 http://www.urle.com - go to this URL (open it in the browser)
因此,将打开 5 个浏览器窗口
然后,等待 5 秒,然后获取接下来的 3 个网址
6 http://www.urlf.com - go to this URL (open it in the browser)
7 http://www.urlg.com - go to this URL (open it in the browser)
8 http://www.urlh.com - go to this URL (open it in the browser)
因此,将打开 3 个浏览器窗口
重复上述获取3个url的步骤,直到没有剩余的url可通过,操作结束。
}
$statement->close();
?>
请帮助指导我正确的方向,以便我可以解决这个问题。我们将非常感谢您提供的任何意见或指导。谢谢。
最佳答案
回答 您可以使用网络驱动程序。
我认为这个有一些相当大的名字,https://github.com/facebook/php-webdriver
对于计时,可以使用sleep http://php.net/manual/en/function.sleep.php 在 foreach 循环中的每次迭代中休眠 5 秒,一次 5 秒,使用网络驱动程序打开..
如果您有更多细节,我可以举几个例子。
关于php - 以时间间隔批量访问 URL PHP MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37974368/