PHP in Windows combined with bat batch processing to achieve verification proxy IP server function
1、 Capture and verify proxy through curl of PHP
Second, multi process processing through bat
Third, merge the results of multi process processing
PHP in Windows combined with bat batch processing to achieve verification proxy IP server function
due to business, proxy server is needed. There are many sites providing proxy server information on the Internet, so you can get information from these sites. However, due to the network or other reasons, some of the obtained IP is inaccessible, so we need to do verification filtering to get the proxy server that can be used.
1、 Capture and verify proxy through curl of PHP
grab with curl
thinking
1. Curl grabs website content;
2. Simple_ html_ DOM (click to download) parses the captured content, parses the key information, and saves the file (or cache);
3. Perform curl verification on the key information (IP and port of proxy server);
4. Verification is divided into HTTPS and HTTP methods, which should be distinguished.
2、 Multi process processing by bat
thinking
1. A single CMD window can run a php.exe Process, multiple processes can run multiple processes;
2. Modify the PHP program, support the parameter transfer of CLI mode, different website links can be captured through different parameters;
3. Run multiple CMDS through the start command (view the description), and use & amp; Connect, make main.bat File;
4 main.bat The running status of other CMD windows can be monitored in the file, which can be obtained in the tasklist by setting the title of the CMD;
5. After the running of other CMD windows (PHP tasks) is completed, the result set is merged.
3、 Merging the results of multiprocessing
take out the file saved in the first step, and then merge the result with PHP code, and output it to result_ xxx.json It can be done in the middle;
The code will not be posted for the time being. It will be updated later.