luguokankan 發表於 2013-9-14 17:32 
" n. W( u) R& M7 Q做出來記得給我一份啊 / H& R, [' e" N5 n8 A6 F, ?: i
您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 $ J) K5 V* L9 ~; a# u4 w
: i' `: ~1 T4 i8 W
這個是我實現的代碼:, f3 J& o; Q: M' I7 \
' a" e8 {# ]5 R ^1 `
<?php
% |; u7 t1 A! `( a7 h$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';
) N2 r4 l' o+ ~0 ?
. I/ b2 h" @5 M1 q5 i$header = get_header($url);
' o- D, M0 ~% ~/ j9 Pecho $header;
$ h) J5 b0 t& ^9 C9 p! ^
9 v# I% @+ [( o7 e7 x) u# e9 hfunction get_header($url){/ y; o2 `1 U! U
$ch = curl_init();
! y* E! g- c/ o4 O3 D4 M0 N# ] curl_setopt($ch, CURLOPT_URL, $url);
5 I, X5 |- Z# q curl_setopt($ch, CURLOPT_HEADER, true);7 m; f- s0 _+ q S
curl_setopt($ch, CURLOPT_NOBODY,true);
8 m6 o, b0 l( Y7 E' R curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
& i) L' F! b+ e //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);$ N0 m9 o3 u5 |; h: O
curl_setopt($ch, CURLOPT_AUTOREFERER,true);4 P5 }( Y* O+ j9 _6 C! @, G/ @
curl_setopt($ch, CURLOPT_TIMEOUT,30);
3 W2 [0 i; n- G* H" T curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+ \5 W8 p9 ~& a, @2 Q8 a 'Accept: */*',
3 A0 S6 M X5 P- y* }6 O1 ^, r 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
* r7 Q2 ^- K! A+ E 'Connection: Keep-Alive'));. p6 E- C, h( J X0 J
$header = curl_exec($C);
- h1 L" q) \% D1 x d+ d/ S, t return $header;5 {/ l$ R9 _$ P# ?7 e
}
$ x6 x3 ^6 E. _4 C; P?> $ n& O0 ^! Z2 ]0 v, J$ N
0 w; W) Q3 {1 w' B/ P
! Z5 i2 v+ G5 {0 r
; ?" P& H9 v& @/ A& l) Y
運行後的結果:
) u B2 w" ^2 k9 q1 c! J+ J. F! @+ w8 m* Y6 v! b# N
" w6 y* s* X0 G! ~ r" W
- g0 I9 d) q2 p M7 f2 H+ o1 m
% X0 v' r- R% E& [
6 Q, Y+ r) U z
9 b0 y! B2 }$ y1 Y6 @; S8 Y3 {1 a$ [ a" s% ]: v3 s
, \% O" K# K4 X' {3 i3 Z$ h' c; Q l+ ]* G/ j5 F& l/ s; w
" W1 {$ ]2 Q- H- @
|