You can use this collection first and then use the Empire to process
####################################################################################
#作者: 9elong
#网站: A small personal station
#时间: 2007-01-01
#声明: Used only for PHP learning.
#功能: Capture a single page picture.
#说明: 3 Demo forms have been written to demonstrate. Without any feature description, everything is in the source code. Additional Forum photo collection regular demonstration
####################################################################################
The function of capturing a picture from an information page
function getimg ($url, $n, $key, $imgqian, $imgbiao, $titlekey)
{
$key Picture Address Regular
$titlekey Picture Title Regular
$imgqian Picture Address prefixes
$imgbiao Image Address Special identification
Global $n;
Global $msg;
Global $result;
Global $imgadd;
Global $title;
$msg =file_get_contents ($url);
$key =str_replace ("{Picture address}", "(. +)", $key);
$key = "|". $key. "| IsU ";
Preg_match_all ($key, $msg, $result);
$c =count ($result [0]);
for ($i =0; $i < $c; $i + +)
{
$img = $result [0][$i]. "
";
if (Ereg ("^.*". $imgbiao. ". *$ ", $img))
{
$img =str_replace ($imgbiao, $imgqian. $imgbiao, $img);
Preg_match ("|http://(. +) Jpg|isu", $img, $img);
$imgadd [$n]= $img [0];
echo "
";
$n + +;
}
ElseIf (Ereg ("^.*jpg.*$", $img))
{
Preg_match ("|http://(. +) Jpg|isu", $img, $img);
$imgadd [$n]= $img [0];
if ($img [0]!= "")
$n + +;
}
Unset ($IMG);
}
$titlekey =str_replace ("{Picture caption}", "(. +)", $titlekey);
$titlekey = "|". $titlekey. "| IsU ";
Preg_match ($titlekey, $msg, $title);
echo $title [0];
return $title;
return $msg;
return $result;
return $n;
return $imgadd;
}
####################################################################################
The #不支持file_get_contents () function can use the following substitution
# $i = 0;
# $handle = @fopen ($url, "RB");
#while (! @feof ($handle))
#{
# $buffer [$i]= @fgets ($handle, 4096);
# $i + +;
#}
#fclose ($handle);
# $msg =join ("", $buffer);
####################################################################################
if ($_get[' act ']== "getimgadd" &&$_post[' url ']!= "")
{
$url =$_post[' url '];
Getimg ($url, "0", $_post[' key '],$_post[' Imgqian '],$_post[' Imgbiao ',],$_post[' Titlekey ']);
####################################################################################
Get pagination
if ($_post[' getpage ']== "yes")
{
$_post[' page ']=str_replace ("{Paging address}", "(. +)", $_post[' page '));
$page = "|". $_post[' page ']. "| IsU ";
Echo $page;
Preg_match_all ($page, $msg, $presult);
if ($_post[' PC ']== "" | | $_post[' PC ']== "all")
$PC =count ($presult [0]);
Else
$pc =$_post[' pc '];
if ($_post[' PC ']>count ($presult [0])
$PC =count ($presult [0]);
for ($i =1; $i < $pc; $i + +)
{
$pageurl = $presult [0][$i];
echo $pageurl. "
";
if (Ereg ("^.*[1-9].*$", $pageurl))
{
$pageurl =str_replace ("$pagekey =str_replace (" {Key address} "," (. +) ", $_post[' Pagekey ']);
$pagekey = "|". $pagekey. "| IsU ";
Preg_match ($pagekey, $pageurl, $N 3[$i]);
Echo ($N 3[$i][0]). "
";
Getimg ($N 3[$i][0], $n, $_post[' key '],$_post[' Imgqian '],$_post[' Imgbiao '],$_post[' Titlekey ']);
}
}
}
####################################################################################
echo "Picture set". $title [1]. " ". $n." Picture is crawled
Back to Home
";
while (list ($num, $var) =each ($imgadd))
{
if ($_post[' ShowType ']== "picture")
{
echo "
";
}
Else
echo $var. "
";
}
####################################################################################
Exit ();
}
?>
Example 1 (The information page has pagination and uses a simple paging regular):
Instance 2 (Information page is not paged, so the paging is empty):
Example 3 (the information page is not paged, so the paging is empty, the image is an absolute address, so the image address prefix is empty):
China Voice Forum photo for attachment http://bbs.hnol.net/dispbbs2.asp?boardID=50&ID=336436
Image address Regular: upload=jpg{image address}upload
Image Address ID: BBS
Picture Title Regular: Post topic: {Picture Title}
China Voice Forum picture for the outside chain http://bbs.hnol.net/dispbbs2.asp?boardID=50&ID=336253
Image address Regular: img]{image address}/img
Image address ID: jpg
Picture Title Regular: Post topic: {Picture Title}
The above describes the acquisition of the primary PHP-written collection procedures, including the content of the collection, I hope that the PHP tutorial interested in a friend helpful.