luguokankan 發表於 2013-9-14 17:32 
: ?0 `9 H" S3 N5 A" w: [+ ?做出來記得給我一份啊
/ h' E, @/ x! o! i; k2 Y" E您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 
. } f7 C0 H9 k! q& U& K2 f- {% J; l2 n' j, U8 K+ V, O/ z6 z
這個是我實現的代碼:
7 j8 {1 p1 C- a+ k# A- R" l+ W, u8 w' k. g8 Z' f; @- B$ D6 {8 g+ x* v
<?php. G3 Z5 }; x% L: O% N$ H; U9 n8 h4 d4 L
$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';1 Q% Q- k1 X& M6 c0 [. i( n% k
+ s5 y6 H, W2 l( e: \. A$header = get_header($url);
7 c* `' b. ]3 Recho $header;: w$ x" W+ ^ k! F/ g* O
% ^( ^( v- j6 X( L# Q5 H, y6 R9 E
function get_header($url){2 R/ E1 p- v0 i9 z2 p, F7 P8 s
$ch = curl_init();
v( n* s6 z5 w4 ` curl_setopt($ch, CURLOPT_URL, $url);
" K' M: v/ |4 r curl_setopt($ch, CURLOPT_HEADER, true);# h! W9 b" D, R" S* |
curl_setopt($ch, CURLOPT_NOBODY,true);8 A2 a6 R& f& p7 o* ^
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);; i/ ]+ |. @" ?6 H8 D! V: X* g
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);+ ~8 r* F9 ]1 p# W) ~, d5 S8 O6 ^
curl_setopt($ch, CURLOPT_AUTOREFERER,true);+ ^) C, Q+ W6 ~- c& B8 b4 y0 }* |
curl_setopt($ch, CURLOPT_TIMEOUT,30);9 ^/ A7 o; N; R" X' _
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
* n, k7 @& k1 z! W 'Accept: */*',/ H! D+ B8 r7 v5 w4 _0 w
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',: B5 P% Z6 s0 |0 c9 q* n; M
'Connection: Keep-Alive'));
: R* H. @& i4 P$ o" O& m# U* q $header = curl_exec($C);
* X, }& s: E2 l4 S( K# t( V return $header;
4 H s% \2 }; ?+ g/ c4 z/ g}
' e1 n% ^. V7 M3 {?>
. S# s/ s; |& P
# t: ?* R ^! s* G. [1 p: l8 E4 `& c+ Y
6 x! b6 x' B. H5 N; P/ k0 l運行後的結果:& `* g: o }: m# i9 ?' z; }& l
S6 l8 c$ X+ _2 g2 ^2 X- g3 p6 q7 `0 |/ e# A+ e/ V
! P: v8 g& j( J; |( D7 L+ C# N1 Y: S5 S1 i: ^
5 a% y2 a/ c4 `$ P9 H& I4 s
1 k) v/ A% n/ r* G4 U5 a' u
' d' X. I% t4 Y; l
2 n/ o; o r! P9 o1 |% w; G! h O& i
5 i/ a9 B* y# W7 z# i" e |