You can use this collection first and then use the empire to process it.
<? Php
######################################## ######################################## ####
# Author: 9 elong
# Website: personal websites are not worth mentioning
# Time: 2007-01-01
# Declaration: it is only used for learning php.
# Function: collect images on a single page.
# Note: regular expressions have been written in three demonstration forms for demonstration. There is no function description, and everything is in the source code. Demonstration of adding Forum image collection Regular Expressions
######################################## ######################################## ####
// Function for capturing an image from the Information Page
Function getimg ($ url, $ n, $ key, $ imgqian, $ imgbiao, $ titlekey)
{
// $ Key: Image address regular
// $ Titlekey: Image title regular
// $ Imgqian image address prefix
// $ Imgbiao image address special identifier
Global $ n;
Global $ msg;
Global $ result;
Global $ imgadd;
Global $ title;
$ Msg = file_get_contents ($ url );
$ Key = str_replace ("{image 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]. "<br> ";
If (ereg ("^. *". $ imgbiao. ". * $", $ img ))
{
$ Img = str_replace ($ imgbiao, $ imgqian. $ imgbiao, $ img );
Preg_match ("| http: // (. +) jpg | isU", $ img, $ img );
$ Imgadd [$ n] = $ img [0];
// Echo " <br> ";
$ 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 ("{image title}", "(. +)", $ titlekey );
$ Titlekey = "|". $ titlekey. "| isU ";
Preg_match ($ titlekey, $ msg, $ title );
// Echo $ title [0];
Return $ title;
Return $ msg;
Return $ result;
Return $ n;
Return $ imgadd;
}
######################################## ######################################## ####
# The following replace is not supported for the file_get_contents () function
# $ I = 0;
# $ Handle = @ fopen ($ url, "rb ");
# While (! @ Feof ($ handle ))
#{
# $ Buffer [$ I] = @ fgets ($ handle, 4096 );
# $ I ++;
#}
# Fclose ($ handle );
# $ Msg = join ("", $ buffer );
######################################## ######################################## ####
If ($ _ GET ['ac'] = "getimgadd" & $ _ POST ['url']! = "")
{
$ Url = $ _ POST ['url'];
Getimg ($ url, "0", $ _ POST ['key'], $ _ POST ['imgqian '], $ _ POST ['imgbiao'], $ _ POST ['titlekey']);
######################################## ######################################## ####
// Retrieve the page
If ($ _ POST ['getpage'] = "yes ")
{
$ _ POST ['page'] = str_replace ("{pagination 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. "<br> ";
If (ereg ("^. * [1-9]. * $", $ pageurl ))
{
$ Pageurl = str_replace ("<a href =" "," <a href = "". $ _ POST ['imgqian '], $ pageurl );
$ Pagekey = str_replace ("{Key address}", "(. +)", $ _ POST ['pagekey']);
$ Pagekey = "|". $ pagekey. "| isU ";
Preg_match ($ pagekey, $ pageurl, $ N3 [$ I]);
// Echo ($ N3 [$ I] [0]). "<br> ";
Getimg ($ N3 [$ I] [0], $ n, $ _ POST ['key'], $ _ POST ['imgqian '], $ _ POST ['imgbiao'], $ _ POST ['titlekey']);
}
}
}
######################################## ######################################## ####
Echo "image set [". $ title [1]. "]". $ n. "captured images <br> <a href = '? Act = '> back to homepage </a> <br> ";
While (list ($ num, $ var) = each ($ imgadd ))
{
If ($ _ POST ['showtype'] = "image ")
{
Echo " <br> ";
}
Else
Echo $ var. "<br> ";
}
######################################## ######################################## ####
// Exit ();
}
?>
Instance 1 (the Information Page has pagination, and a simple paging regular expression is used ):
<Form method = post action = "? Act = getimgadd ">
INPUT Image address <input type = "text" NAME = "url" size = 80 value = 'HTTP: // www.pp132.com/n835c17.shtml'> <br>
Image address Regular Expression <input type = "text" NAME = "key" size = 80 value = ''> <br>
Image address prefix <input type = "text" NAME = "imgqian" size = 80 value = 'HTTP: // www.pp132.com/'> <br>
Image address id <input type = "text" NAME = "imgbiao" size = 80 value = 'upload'> <br>
Image title regular <input type = "text" NAME = "titlekey" size = 80 value = '<H1 class = aTitle> {image title} </H1> </DIV>'> <br>
Pagination address regular <input type = "text" NAME = "page" size = 80 value = '<a href = "{pagination address} shtml">. [0-9] '> <br>
Paging address mode <input type = "text" NAME = "pagekey" size = 80 value = 'HTTP: // {Key address} shtml'> <br>
<Select name = "getpage">
<Option value = "yes" selected = "selected"> retrieve paging information </option>
<Option value = "no"> do not paging information </option>
</SELECT> <br>
<Select name = "pc">
<Option value = "1" selected = "selected"> get 1 page </option>
<Option value = "2"> Get 2 pages </option>
<Option value = "3"> 3 pages </option>
<Option value = "4"> get 4 pages </option>
<Option value = "5"> get 5 pages </option>
<Option value = "all"> get all </option>
</SELECT> <br>
<Select name = "showtype">
<Option value = "image" selected = "selected"> display images directly </option>
<Option value = "text"> direct display address </option>
</SELECT> <br>
<Input type = "submit">
</FORM> <br>
Instance 2 (there is no paging on the information page, so the paging regular is blank ):
<Form method = post action = "? Act = getimgadd ">
INPUT image url <input type = "text" NAME = "url" size = 80 value = 'HTTP: // zy.muwen.com/pic/89/2007/01/01/131721.htm'> <br>
Image address Regular Expression <input type = "text" NAME = "key" size = 80 value = ' <br>
Image address prefix <input type = "text" NAME = "imgqian" size = 80 value = 'HTTP: // zy.muwen.com/'> <br>
Image address id <input type = "text" NAME = "imgbiao" size = 80 value = 'upload'> <br>
Image Title regular <input type = "text" NAME = "titlekey" size = 80 value = '<span id = "_ ctl0_TitleLabel" class = "Title"> {image Title} </span> </TD> '> <br>
Pagination address regular <input type = "text" NAME = "page" size = 80 value = ''> <br>
Paging address mode <input type = "text" NAME = "pagekey" size = 80 value = ''> <br>
<Select name = "getpage">
<Option value = "yes"> retrieve paging information </option>
<Option value = "no" selected = "selected"> do not paging information </option>
</SELECT> <br>
<Select name = "pc">
<Option value = "1" selected = "selected"> get 1 page </option>
<Option value = "2"> Get 2 pages </option>
<Option value = "3"> 3 pages </option>
<Option value = "4"> get 4 pages </option>
<Option value = "5"> get 5 pages </option>
<Option value = "all"> get all </option>
</SELECT> <br>
<Select name = "showtype">
<Option value = "image" selected = "selected"> display images directly </option>
<Option value = "text"> direct display address </option>
</SELECT> <br>
<Input type = "submit">
</FORM> <br>
Instance 3 (there is no paging on the information page, so the paging regular is blank, the image is an absolute address, so the image address prefix is blank ):
<Form method = post action = "? Act = getimgadd ">
INPUT Image address <input type = "text" NAME = "url" size = 80 value = 'HTTP: // www.6642.com/Disp/9936.htm'> <br>
Image address Regular Expression <input type = "text" NAME = "key" size = 80 value = '<P> </P>'> <br>
Image address prefix <input type = "text" NAME = "imgqian" size = 80 value = ''> <br>
Image address id <input type = "text" NAME = "imgbiao" size = 80 value = 'upload'> <br>
Image title regular <input type = "text" NAME = "titlekey" size = 80 value = '<div align = "right"> <B> {image title} </B> </div> </td> '> <br>
Pagination address regular <input type = "text" NAME = "page" size = 80 value = ''> <br>
Paging address mode <input type = "text" NAME = "pagekey" size = 80 value = ''> <br>
<Select name = "getpage">
<Option value = "yes"> retrieve paging information </option>
<Option value = "no" selected = "selected"> do not paging information </option>
</SELECT> <br>
<Select name = "pc">
<Option value = "1" selected = "selected"> get 1 page </option>
<Option value = "2"> Get 2 pages </option>
<Option value = "3"> 3 pages </option>
<Option value = "4"> get 4 pages </option>
<Option value = "5"> get 5 pages </option>
<Option value = "all"> get all </option>
</SELECT> <br>
<Select name = "showtype">
<Option value = "image" selected = "selected"> display images directly </option>
<Option value = "text"> direct display address </option>
</SELECT> <br>
<Input type = "submit">
</FORM> <br>
Huasheng Forum pictures for the attachment http://bbs.hnol.net/dispbbs2.asp? BoardID = 50 & ID = 336436
Image address regular: upload = jpg {image address} upload
Image address ID: bbs
Image title regular: Post topic </B >:{ image title} </th>
Huasheng Forum pictures for the external chain http://bbs.hnol.net/dispbbs2.asp? BoardID = 50 & ID = 336253
Image address regular: img] {image address}/img
Image address ID: jpg
Image title regular: Post topic </B >:{ image title} </th>