使用代理 IP

优质
小牛编辑
124浏览
2023-12-01

http代理

<?php
$http = HttpRequest::newSession();
$response = $http->proxy('127.0.0.1', 808) // 常见的http代理这样用
                 ->get('https://www.baidu.com/');
$content = $response->body(); // 网页源码

socks代理

<?php
$http = HttpRequest::newSession();
$response = $http->proxy('127.0.0.1', 808, 'socks5') // 支持http、socks4、socks4a、socks5
                 ->get('https://www.baidu.com/');
$content = $response->body(); // 网页源码