luguokankan 發表於 2013-9-14 17:32 
6 m. L# [$ ~5 c& N: r; ~3 M( W# t: o做出來記得給我一份啊 0 ^% w8 J. N. ]8 l4 U1 n& a
您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 
! S" B* d% C1 f
: K! L- N/ i& N3 l* q這個是我實現的代碼:6 W5 h1 Z% l% {4 k
9 a$ M8 W- A1 p4 [6 ?<?php$ H# o' N# B( Z m+ g1 L0 M. ^
$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';1 {1 B1 i0 m7 V) Y& f6 u s* k
5 e5 f7 ^! e# ^" O# I
$header = get_header($url);
# H$ k, p* ~2 D7 |) w6 wecho $header;
& l3 t a* d& C2 F
" {1 T) }" a) i6 ~function get_header($url){
8 Q9 u+ a; e, x" I $ch = curl_init();, {/ t- Z' q x- _6 v
curl_setopt($ch, CURLOPT_URL, $url);
* I/ W: j: q/ K8 e: ~& [2 R2 P9 Q, M curl_setopt($ch, CURLOPT_HEADER, true); {% V" o* d( I5 Z2 V
curl_setopt($ch, CURLOPT_NOBODY,true); E R' r& \* ^/ F; v
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
! ]1 j9 w8 A- T* I //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
# H, P) K8 T; w. m' e curl_setopt($ch, CURLOPT_AUTOREFERER,true);8 k! I# t$ I8 h) Q4 o: r0 E
curl_setopt($ch, CURLOPT_TIMEOUT,30);% D2 g2 w; |6 B8 I1 S( ]+ g+ `
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
5 p+ G9 v, u' _# |( l% }8 _: n- A 'Accept: */*',
7 C# x) `9 ]: S7 ^0 T% g 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
' T# m3 x) B- t4 z1 R 'Connection: Keep-Alive'));! a& c3 \$ ^ A
$header = curl_exec($C);
( W, K& @) k4 X; `9 @ return $header;
4 u9 Y ]$ S2 a: m% ^4 l8 L7 g" b}& B% W: H( q" o) c2 I! c3 R7 N* f3 t
?> 5 Y% w0 n8 N4 M. @. c: L! G1 V' }
/ z+ i, \! ~* j4 t* G9 h) h2 N" Q2 O9 q! x
9 B/ Q$ M- [7 L) M( O( i; l7 _0 H; i1 @, c+ z8 t6 X& @4 i
運行後的結果:5 s8 e- t c( g) k
. w/ C5 e' a, P/ g
* ^, P$ K3 E/ ~1 R: b/ |! @; h8 w: v5 c0 c: c! q! [$ S
. t7 t/ z8 u; `' R
X0 b" `9 a$ E# _" d! A- U# I5 [. Z* a& q) |5 d
/ O2 z: ~& V! e0 t( M
8 y+ b( G- R0 Q$ A J
+ |, c9 U% o5 D! z2 |5 M
% ~2 {- W: P/ F0 x7 M4 S+ ^: [
|