luguokankan 發表於 2013-9-14 17:32
4 K: w: C" _- }, x做出來記得給我一份啊
: s) M' u" B0 \% j# o }6 k您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 + P2 u# A8 n: h* S s# Q
% R3 D4 F7 E7 \# G% Q+ Q( f9 p這個是我實現的代碼:
3 _0 K& g" H7 M9 \" F6 U# _8 E! v$ g# {; A
<?php
+ H! Q! ?' k) l/ ^4 [4 o$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';
/ A: c. j0 c# K' K Z. y& u2 u; ~& N F J
$header = get_header($url);, i' g# s2 o0 A2 O# t- R
echo $header; ?4 [: ^& i0 O) v9 u% u. v( I
( _4 [' m; {: h s# g
function get_header($url){
6 [4 {1 {* @- V8 M6 R' j4 E $ch = curl_init();
) d$ D; r; l' Z2 d6 n2 L curl_setopt($ch, CURLOPT_URL, $url);' A) S3 u5 X: F" f
curl_setopt($ch, CURLOPT_HEADER, true);
( j: L4 C8 B7 D curl_setopt($ch, CURLOPT_NOBODY,true);
& m8 Y# C+ y4 d: X% ? curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
2 ~- }; `4 b- \( `: p //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
* u" }1 [0 H9 S( P curl_setopt($ch, CURLOPT_AUTOREFERER,true);5 ?& u: g J* a
curl_setopt($ch, CURLOPT_TIMEOUT,30);6 h. p9 O% H. i/ R# d6 a
curl_setopt($ch, CURLOPT_HTTPHEADER, array(/ f" R, }# m8 J( J9 S3 r
'Accept: */*',
; V% g0 _1 Q, r. ` 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
, X+ Q7 x. w; ?* U) w 'Connection: Keep-Alive'));. z( S ?. x, r P
$header = curl_exec($C);7 J# T& Q3 q! K2 K+ x
return $header;
4 T3 S! Q1 r4 e! L* c" q) T; V}
! i O' M0 _; K+ S, O& B; t" ]?>
% N/ K& |4 p1 J4 y4 K4 @; Y& u+ C, a1 S
/ c! ?: ?% c! g6 `+ ^3 q, Q1 |# U2 H/ Z. O8 d
運行後的結果:! P6 L( l# s5 A
+ J' h0 R$ p- S: _3 A* }2 _9 k" B6 y& w1 q& p2 \4 \& y, @
8 c1 o5 X% U! {8 j1 c4 F+ ]3 v( ]1 } [) p+ }6 C
6 m* z5 Q x# m1 p; G8 x/ V& m6 a5 P3 i/ b9 o
1 H0 P* p% f) `! q
% y q" w2 r7 m# K, ]& u6 U) s. `- `; V5 c( |
: G& P+ q4 E! [ Q
|