How to implement the function of dynamically changing IP in the program, the IP address can be purchased from a certain treasure
ringa_lee2017-05-18 10:49:10
If your program is a client to request others, you can use http proxy. For example, how to configure http proxy using curl:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://baidu.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理认证模式
curl_setopt($ch, CURLOPT_PROXY, "xxx.xxx.xxx.xxx"); //代理服务器地址
curl_setopt($ch, CURLOPT_PROXYPORT, 80); //代理服务器端口
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, ":"); //http代理认证帐号,username:password的格式
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //使用http代理模式
$file_contents = curl_exec($ch);