The PHP collection of a single file saves the collected id data to a txt file, and runs the php file to automatically run the collection, mainly to understand a collection principle of PHP, it is not suitable for direct website application. this program is a program that collects beautiful pictures of the world's mm Forum. this file uses the ID of the target website after opening and collecting the website, then, save the ID to the txt file, and form a set of PHP collections that collect a single file in the txt file. then, save the collected id data to a txt file, you can run the php file to automatically run the collection. it is mainly to understand a collection principle of php and is not suitable for direct website applications. this program is a program for collecting beautiful pictures on the mm Forum, this file uses open the target website address, collect the ID of the website address, and save the ID to the txt document. in the txt document, a set of collected IDs are formed, we can use this program to collect an ID from other websites, and then use the principle of single file collection for warehouse receiving, but this file needs to be modified as appropriate.
The following is the source file:
PHP code
-
- Session_start ();
- $ T = time ();
- $ Arr = explode ("\ n", file_get_contents ("a.txt "));
- $ Id =! Isset ($ _ GET ['id'])? 0: trim ($ _ GET ['id']);
- $ Tid = trim ($ arr [$ id]);
- If (! Isset ($ _ SESSION ['I])
- {
- $ Url = "http://tianxiamm.com/viewthread.php? Tid = ". $ tid." & extra = page % 3D2 ";
- If (! $ Content = file_get_contents ($ url ))
- {
- Exit ("script location. href = 'D. php? Id = ". ($ id + 1)." '; script ");
- }
- Preg_match_all ("| iUs", $ content, $ addr );
- If (emptyempty ($ addr [1])
- {
- Exit ("script location. href = 'D. php? Id = ". ($ id + 1)." '; script ");
- }
- $ _ SESSION ['addr '] = $ addr [1];
- $ _ SESSION ['I'] = 0;
- }
- For ($ I = $ _ SESSION ['I']; $ I <count ($ _ SESSION ['addr ']); $ I ++)
- {
- If (! File_exists ($ tid ))
- {
- Mkdir ($ tid, 0777 );
- }
- If ($ a = file_get_contents ($ _ SESSION ['addr '] [$ I])
- {
- $ Fuffix = substr ($ _ SESSION ['addr '] [$ I], strrpos ($ _ SESSION ['addr'] [$ I], '. '), 5 );
- $ FileImg = $ tid. '/'. ($ I + 1). $ fuffix;
- File_put_contents ($ fileImg, $ a); // write the file
- }
- $ _ SESSION ['I'] = $ I + 1;
- If (time ()-$ t> 18)
- {
- Exit ("script location. href = 'D. php? Id = ". $ id." '; script ");
- }
- }
- Unset ($ _ SESSION ['addr ']);
- Unset ($ _ SESSION ['I]);
- Exit ("script location. href = 'D. php? Id = ". ($ id + 1)." '; script ");
- ?>
A.txt is a data file
D. php is an image collection program and can be opened and run directly in the browser.