luguokankan 發表於 2013-9-14 17:32 * R/ N! Y+ z& c' H3 Z- z$ H6 J
做出來記得給我一份啊
7 H5 {6 @6 h& R) ^您這樣的大牛,博士生導師級別的, 拿小弟開玩笑吧 呵呵 9 r% ?( ~3 O( l- W6 b
3 Y2 [% G: \% `這個是我實現的代碼:
/ E, \1 q# X$ J
% @5 H4 |4 v' q) {8 W<?php9 _+ j- ~1 Z0 p
$url = 'http://arcadegameworld.com/play/stone-age-mahjong-connect/';
+ M! h# E* {3 p, z5 n* D' X- ?2 q7 z- D; B9 q9 R' V0 L7 w
$header = get_header($url);$ R( B! N" e2 H* a: B! |
echo $header;, U) o, C7 i1 g% B2 F
6 g) y- M8 V; ]5 [. p. g/ t% ?function get_header($url){
l3 F' T. W# J/ Y& {' ` $ch = curl_init();$ T0 q" M0 a; R' R
curl_setopt($ch, CURLOPT_URL, $url);5 S& O9 m- R2 K0 }& ^' C* n
curl_setopt($ch, CURLOPT_HEADER, true);
/ ^0 {! P S/ Q) [4 f curl_setopt($ch, CURLOPT_NOBODY,true);
9 z8 Y% ]% a; B curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
; L$ } U# P. o: A4 ^! a- `8 d5 K //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);; x& P; C' o5 l; r1 A2 D
curl_setopt($ch, CURLOPT_AUTOREFERER,true);
w: @6 n/ f$ g' W/ m( f6 `7 O5 d curl_setopt($ch, CURLOPT_TIMEOUT,30);
6 @" L- M6 h) i. e curl_setopt($ch, CURLOPT_HTTPHEADER, array(
; N! G4 K! F, E$ F 'Accept: */*',: U1 R, i+ h( }( B/ k
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)',( y# W( W* j2 {- ~
'Connection: Keep-Alive'));3 Y# l4 B! A- U1 s) Y2 q" F
$header = curl_exec($C);
5 [; m. q# M4 k# U: D- O' g- { W return $header;
+ L+ u6 K( o* k; s5 D' E}
( `" b U! L: S2 o* i?> 2 E8 \) o$ {% }0 t: X# n& P
+ ` g9 m4 R: @
3 M' G& R$ E9 s `7 `' u. r* Q
& D/ c! B8 C6 y: `, e W& ?
運行後的結果:4 q h" F! C. Q/ }
" t; K: {1 V4 G( R
1 D; m3 O4 f0 a: Y5 l# C: N, i2 M% q0 R2 w3 w! N
3 T% w* Y7 j7 @0 ]% Z; Y( D& m$ p7 P
! K4 e9 G+ \! k
3 t, o, P- w) c1 ~% H3 s4 h5 M8 E4 c, ]5 d" n" p
5 \$ g: p$ O2 c* `. B
8 n+ x1 S) \1 ]/ ?; [
0 S) l3 ], C3 A7 \0 R6 ~5 s |