简单遍历id抓取
<?php
$file = file_get_contents('/www/spider/text.txt');
echo $c=$file;
$end=$c+40;
for ($i=$c; $i<=$end; $i++) {
$url="https://www.xxx.com/spider.php?id=".$i;
$r = file_get_contents($url);
}
$rend=$end+1;
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$fp = fopen("/www/spider/text.txt",'w');
fwrite($fp,$rend);
fclose($fp);
?>
<?php
$con = mysql_connect("localhost","root","mima");
if (!$con)
{
die('连接数据库失败');
}
mysql_query("SET NAMES 'utf8'",$con);
mysql_select_db("data") or die("数据库不存在!");
$sql = "select id,status from table where status='0' order by id asc limit 30";
$result99 = mysql_query($sql,$con);
while($row=mysql_fetch_array($result))
{
echo $url="https://www.xxx.com/content.php?id=".$row[id];
$r = file_get_contents($url);
}
mysql_close($con);
?>