This article describes the PHP Thief program Design and implementation methods. Share to everyone for your reference, specific as follows:
In fact, I have always wanted to do a connotation of the image of the site, the previous idea is to do a CMS, and then upload some pictures of their own.
The first thing to do is to have no motivation. Then gave up, then studied a curl. Anyway, it is better to achieve this idea.
Using PHP to steal pictures is like wearing sandals in socks. It's no problem, but it does hurt.
Let me first say my PHP thief program design, PHP does not support multithreading, so you can only do in a sequential order
Get to the target site HTML page + parse HTML page get to picture storage connection + read in binary mode and save locally + rename = = Process OK
The first kind: Use the tour to run the program (most will be stuck to death, set timeout and memory size on OK, you are more difficult between)
is the process by which an HTML page acquires an IMG connection address.
uses two more important things:
1.PHP Dom resolution extension simplehtmldom
2.PHP Directory iterator The
understands these two things. There is no difficulty with this analytic class.
Is talking about getting the page you want to parse? The
is actually the same as the above principle. Main gets the URL of the page, and then through Curl to read the page, return an HTML string,
and save the Function package HTML page saved to the local.
I am here because I want to capture the picture inside the page (in order to prevent other people's anti-theft chain), so the design is more complex. The
And why it is separated is because the Simplehtmldom object is large, and it is more clear that the process is disassembled.
Surely someone would say, why don't you just skip the HTML and save it to the local part, bingo! I can only bother to write the regular.
More interested readers of PHP-related content can view the site topics: "Php Curl Usage Summary", "PHP graphics and pictures Operating skills summary", "PHP Array" operation Techniques Daquan, "PHP common traversal algorithm and skills summary", " PHP Data structure and algorithm tutorial, "PHP Programming Algorithm Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.