写得程序很老土 见笑了;<?php
$mianurl="http://www.xxxx.com.cn";
$typeid=33;
$typename="酷站";
mysql_connect("localhost:3306","root","");
mysql_select_db("kuzhan");
mysql_query("set names 'gbk'");
for($i=1;$i<=21;$i++)
{
$url="http://xxxxxx/".$typeid."/page-".$i.".html";
$str=file_get_contents($url);
preg_match_ALL("/<span><a href=\'(.*)\' target=\'_blank\'>(.*)<\/a><\/span>/isU",$str,$arrayurl);
preg_match_ALL("/target=\"_blank\"><img src=\"(.*)\" width=\"170\" height=\"100\"><\/a>/isU",$str,$arrayimg);
preg_match_ALL("/target=\'_blank\'>(.*)<\/a><\/span>/isU",$str,$arrayname);
foreach ($arrayurl[1] as $a=>$b)
{
echo ++$x;
echo $b."\n";
mysql_query("INSERT INTO web_show(url,id,typeid,typename)VALUES ('$b','$x','$typeid','$typename')");
}
foreach ($arrayname[1] as $e=>$f)
{
echo ++$y;
echo $f."\n";
$queryname="update web_show set webname='$f' where id=$y and typeid=$typeid";
mysql_query("$queryname");
}
foreach ($arrayimg[1] as $c=>$d)
{
//echo ++$z;
//echo "http://www.xxxxxcom.cn/".$d."\n";
//copy($mianurl.$d,"g:\web_show");
$pic=$mianurl.$d;
//想在这里吧$pic下载到本地文件夹里面
$file = basename ($d);
//echo $z.$pic;
$queryimg="update web_show set image='/web_show/$file',webimg='$pic' where id=$z and typeid=$typeid";
mysql_query("$queryimg");
}
}
?>
$pic变量是个完整的图片路径 不知道如何下载,网上找的代码测试结果都不行 请大家帮忙指点下







最新回复