- UID
- 3738
- 阅读权限
- 20
- 注册时间
- 2020-1-3
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
// 要访问的目标页面 o8 P9 c3 T/ X8 T3 W9 z
$url = "http://baidu.org/ip";4 r& r" f* U b* \4 q, g
$urls = "https://baidu.org/ip";' A3 J( S |9 p6 W8 w2 N
S, c/ `, O- ?$ q- [1 [
// 代理服务器; ?8 o4 [5 G$ N ~/ [
define("PROXY_SERVER", "tcp://t.xxxx.cn:31111");* ?" F9 [) ` L0 @
: y4 D* s- l) P9 A0 b3 ? // 隧道身份信息3 U- ?& F( K [' O1 {
define("PROXY_USER", "xxxxx");; F1 \. |- o7 r% E, o$ y
define("PROXY_PASS", "123456");
- O$ f1 o" M; J
' l; F- H6 t. @5 d7 @9 V8 u' T $proxyAuth = base64_encode(PROXY_USER . ":" . PROXY_PASS);
" X% Q2 x$ B- q. O, A8 W
1 s& h7 J6 o f2 c // 设置 Proxy tunnel* r9 D. ^. T7 i
$tunnel = rand(1,10000);! \& c8 P0 m! G% ~8 d2 M
- S0 J: V$ C# R! t2 G $headers = implode("\r\n", [' X) W. Q& u- y& I! X X; B" U1 i1 f
"Proxy-Authorization: Basic {$proxyAuth}",1 y# d0 v$ \% b) Z
"Proxy-Tunnel: ${tunnel}",* h! ^* H5 w( ~2 [
]);8 _3 l8 N3 O3 Q% p) S1 r0 |4 B
$sniServer = parse_url($urls, PHP_URL_HOST);" b% x- W( {' ^2 m \& y
$options = [
4 l2 A$ q' ]7 v$ p "http" => [
' w& a5 h5 b& `# ]3 E! V "proxy" => PROXY_SERVER,
+ b* r# r& J& |5 x2 O( o "header" => $headers,
, F$ l1 E F( u "method" => "GET",
6 [7 Q0 _: U/ o5 m/ v 'request_fulluri' => true,
& Q% h2 d' m7 b5 ^ ],# V# @ B: c3 Z1 }6 |1 p
'ssl' => array($ V$ g$ Y) y* a, u3 r
'SNI_enabled' => true, // Disable SNI for https over http proxies+ O" f8 t# [6 t$ K4 \8 S
'SNI_server_name' => $sniServer
- c- i: q0 Z7 F. B( H+ q )
0 j$ A0 {; ?2 N4 z" [ ];
( y6 Y# K$ n8 ^2 \% c% f" }$ T print($url);
- a: ?6 Y* i9 V4 N $context = stream_context_create($options);, T/ k; B) J% L2 }" T! i4 y
$result = file_get_contents($url, false, $context);+ d9 X5 e7 d( A. b) [) f( i% @
var_dump($result);6 r& `: O; T0 _+ S
: C- N' _0 s2 Q1 n: X // 访问 HTTPS 页面
( P* y1 D4 j9 q1 A! Q print($urls);* V$ ^7 X- X, [" A- {% U* y
$context = stream_context_create($options);- S0 H" u7 |5 U9 S- t G3 h
$result = file_get_contents($urls, false, $context);
. I7 W! R1 N) S1 X z& R+ V$ W var_dump($result); |
|