PHP verifies HTTP proxy availability [batch supported]-PHP source code

Source: Internet
Author: User
0 This program is mainly used to verify the availability of the HTTP proxy, support single verification, and batch verification.


The program is also very simple, and it is still very good for learning.

Project description:
========================================================== ==============================================
1. access index. php directly on the tools. php page of the program portal page. you can also [jump to the program]
2. HTTP proxy verification [URL collection mode] if there are many proxies in it, it is not recommended to use it. the verification takes a long time.
3. use HTTP proxy for authentication in [SINGLE mode]
4. for batch verification, use HTTP proxy verification [fixed format batch verification]. the fixed format is as follows:

221.130.18.125: 80 @ HTTP; Nanjing mobile, Jiangsu province
221.130.18.126: 80 @ HTTP; Nanjing mobile, Jiangsu province
221.130.18.127: 80 @ HTTP; Nanjing mobile, Jiangsu province

The content of each proxy occupies one line. The content after the semicolon does not exist. that is to say, this format must be ensured: 221.130.18.125: 80 @ HTTP;
5. this proxy verification tool only supports HTTP proxy authentication and does not support SOCKS proxy authentication.
6. if the SOCKS proxy is adapted for verification, you only need to modify the core File class/class. proxy. php and modify it in CURL mode.
7. description of config. php configuration file

 'Http: // www.baidu.com/robots.txt', // The URL 'timeout' => 20 used to verify the proxy. 'retry' => 2, // if the verification fails, the number of retries is 'root _ path' => dirname (_ FILE _), 'host' => 'http ://'. $ _ SERVER ['http _ host']);?>

1.

Proxy.zip

2. [File]Class. proxy. php
 Proxy_ip = $ proxy_ip; $ this-> proxy_port = $ proxy_port; $ this-> check_url = $ check_url; $ this-> time_out = $ time_out; $ this-> retry = $ retry;} public function check_proxy () {// create a new cURL resource $ ch = curl_init (); // Set the URL and the corresponding options curl_setopt ($ ch, CURLOPT_URL, $ this-> check_url); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ this-> time_out ); curl_setopt ($ ch, CURLOPT_HEADER, 0); curl_setopt ($ ch, CURLOPT_PROXY, $ thi S-> proxy_ip. ':'. $ this-> proxy_port); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // capture the URL and pass it to the browser $ I = 1; $ result = false; while ($ I <= $ this-> retry) {$ result = curl_exec ($ ch); if ($ result! = False & substr_count ($ result, 'user-agent: Baiduspider ')> = 1) {$ result = true; break;} else {$ result = false ;} + + $ I;} // closes the cURL resource and releases the system resource curl_close ($ ch); // returns boolean true if the system resource is released. RETURNS boolean falsereturn $ result if the system resource fails to be released.}?>

3.[Image]Uiinterface .png


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.