luguokankan 發表於 2013-9-14 17:32 & J; z& A" Y& o% ~' E
做出來記得給我一份啊 ( R# K: @0 |8 ~( T! V( R; F
您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 
) _ p2 P9 k. ^3 n4 C: `: X( `+ s, j5 O
這個是我實現的代碼:
! {6 {2 k b! ~9 Z$ ?, K
* E$ S4 p1 Y3 V) H<?php3 ]! p' R2 {3 R. M5 H
$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';
' z) \1 r* c+ z
& n+ c1 ]& f5 N s- \+ t# g$header = get_header($url);" P1 V7 T/ L) @
echo $header;4 V( k6 z! O( P; j& O, W
/ b% p: t+ \" L: G0 T
function get_header($url){
6 [* V0 B+ J5 c8 t $ch = curl_init();
( I( o) h) b% H% D curl_setopt($ch, CURLOPT_URL, $url);3 g, f. \% M z9 }
curl_setopt($ch, CURLOPT_HEADER, true);
# T; c0 s. p! O8 u" R4 }$ L! _ curl_setopt($ch, CURLOPT_NOBODY,true);
7 b% A5 b- K$ v; Z8 z curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);( O8 B1 \ P& ^
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
+ j$ t/ x1 I+ z/ d3 X/ h9 d, F0 E curl_setopt($ch, CURLOPT_AUTOREFERER,true);2 u" Z' p1 E9 I* L Y4 V. B3 ]
curl_setopt($ch, CURLOPT_TIMEOUT,30);2 [6 v, ]4 a% R; }, n, _ B8 D
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
( a* u. @1 {) k. y 'Accept: */*',7 T1 u# E/ |: Y. h7 G5 ~
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
2 K# [! X& f5 c3 q8 S/ k 'Connection: Keep-Alive'));5 o5 U. t8 a) o" y( @
$header = curl_exec($C);
/ \4 r7 E0 j4 R2 G3 f: L6 d0 w5 _ return $header;7 ?$ j. r: D. j' N, T4 v; ~
}
% {2 ]2 d- m0 _5 g4 f9 g?> ) F+ J9 | B# K1 }. R% X
; k5 N, g. w4 E' B0 s) D% D2 J- A, N* ?+ p9 l
6 f* W& k W% I
運行後的結果:% T; E) k I0 o7 S0 l! ^
$ D+ P# K1 V; L& B) a! S, Z" o+ M9 B4 t5 k1 f( E
9 V% l6 [) y" r0 O8 E, P' n" Y* r, i1 N) A2 B9 z/ L2 l" M
- b) w0 D. ~+ e! d
. I! e' ?$ X9 \: s0 U& h# M2 J4 ]4 g, ^% q- t& u4 n. g% ]
9 `# q7 e4 i* S3 n' G! ~9 `3 W
1 [7 g. ]) z @% i* g
: [. t+ j/ x. J |