luguokankan 發表於 2013-9-14 17:32
& V; g* Y3 Y5 _+ y做出來記得給我一份啊
7 s5 Y" m+ N1 B5 M. s m您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 : R8 Q5 p$ m6 i' r2 {
G2 Y' ^0 b' t- e% x! @
這個是我實現的代碼:6 [8 H" h1 U4 [# ?3 {5 ^& R9 s4 A; j
+ ^& d( W# a4 r( L<?php
) @9 A' }/ l4 a2 |& J2 m! l$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';* N( z; s9 J s
! [/ G; q. C" q5 ^+ y$header = get_header($url);
+ C; G( l" G' i6 B1 w: H: M' qecho $header;
! A' l; h' H; V6 Z6 S7 v9 O, O' M* I/ Y
function get_header($url){) }. P+ |9 i% @& ~& x; W
$ch = curl_init();
. z' c% W$ g9 k) M curl_setopt($ch, CURLOPT_URL, $url);4 E3 h4 f! n: Y1 l3 n% V( m
curl_setopt($ch, CURLOPT_HEADER, true);
6 D$ Z0 N/ [: O# u/ ^, c0 l curl_setopt($ch, CURLOPT_NOBODY,true);
0 B. K- m4 f' Y6 ^* }+ M4 W5 | curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);8 h, p T5 `3 U9 Q% J+ X- o
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);; y3 W# k9 T; p' ^6 K! K R
curl_setopt($ch, CURLOPT_AUTOREFERER,true);
- i8 ~/ H; d- N* X7 ]3 N: T curl_setopt($ch, CURLOPT_TIMEOUT,30);2 E( e; T7 x: B& {9 {9 r3 n0 E
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
$ p" m; K, o$ F! c6 p0 j 'Accept: */*',
2 X, r# w9 f' s9 M 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',
2 c( o+ y* G9 _ 'Connection: Keep-Alive'));
, o* x8 D/ r$ o2 _( l $header = curl_exec($C);
7 [& @0 A7 X- i. e$ @% X return $header;
; ?. {3 b: w) X4 j' j2 {1 z0 K}1 L; l! {, X4 z/ U; U( D
?> 9 T& d7 Q n! H" c8 l
0 l' `5 O8 @4 \' W" X
* d! f2 N0 r4 {+ I# s* k$ [% v2 { c" f' e3 W- @
運行後的結果:& u9 S+ X9 O2 t9 _' M' t# a
% U6 u5 l1 ^$ h) A% r5 k* D- m* s8 E
9 ^/ y2 j; G: _9 e l
: m3 b7 }& [0 d$ @2 @
; |5 Y, \4 k- Q
, u4 K# d; {& L- o* J8 A) m2 d5 v/ n0 V6 B1 B( w
6 ?2 q5 C+ E5 S3 b
3 |# t2 S& y \
9 z4 N! n2 M# d$ f |