luguokankan 發表於 2013-9-14 17:32 # r) H0 j- T: S4 D, \9 z( [! W
做出來記得給我一份啊 / \) F" G5 P: s8 o
您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 / h! N {' v5 Y
% s; Z. ]# Y; ^7 a; p) w, V1 e
這個是我實現的代碼:
) ?# s' d& A8 `8 \1 W: c' P2 B) _8 w: Q7 A( W# B
<?php! X6 b$ ]: }7 H' H' E
$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/'; P/ l: }% K3 l; A" F
0 F6 J7 [ {& r
$header = get_header($url);$ H3 g. \5 H2 ?. ]# ]4 `) b
echo $header;
3 g; ~6 c$ {; {4 _3 g4 O8 l/ m) U7 F! D
function get_header($url){3 s" h5 M2 o, D. z/ X
$ch = curl_init();7 J5 O+ p1 X9 ~0 h4 s5 [
curl_setopt($ch, CURLOPT_URL, $url);
6 ]: `7 U4 V8 P curl_setopt($ch, CURLOPT_HEADER, true);
5 @ `4 \$ ?7 f3 n( R/ Q! [ curl_setopt($ch, CURLOPT_NOBODY,true);# l3 O- ]4 R' M" d4 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);( I9 \2 n& E( J |" Z. A
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);- ?4 O/ V3 H$ O3 t
curl_setopt($ch, CURLOPT_AUTOREFERER,true);
9 n9 A. |$ Y2 k; ^ curl_setopt($ch, CURLOPT_TIMEOUT,30);7 S5 @$ g+ y7 J l
curl_setopt($ch, CURLOPT_HTTPHEADER, array() y6 J; ]# H7 \. B# `9 S. o( V
'Accept: */*',
) B& e b; y$ e7 x. q 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
4 P6 @, I. p1 f, p2 W+ s 'Connection: Keep-Alive'));0 A3 V) V! d9 C; M
$header = curl_exec($C);
- r2 M* n/ c% ?( k; Z6 J T" M return $header;5 u0 T6 M9 J) c, Q9 L- Q1 z
}
! r7 f0 t. Q* S2 g+ E% H1 m?> 7 r8 r7 h+ P! H, K' R. t0 H; O
; {: L' w8 K/ Q& f! Y; G; u+ c& \$ V' u+ A# Z4 [ h
) O* F" y( v- U5 x: M( m$ O運行後的結果:
( T0 j6 G! U) F4 Y* U
* r, u5 w0 }7 \
( E) n/ p, |- E7 V/ [2 { v5 N9 k# O& d' y+ n
. p9 ?/ q4 y0 n- @% b' P: E
* Y% @9 K. c: `0 z
) X2 x( X: K( g. N1 t9 U- ^ O$ `
( T3 P g2 b3 a% ` e7 K1 ?0 Q
$ L( m a3 V; A' j/ g5 z6 m& P, F x5 g; w9 U7 e
8 G5 A5 F5 p8 Q8 F |