本帖最後由 xx19941215 於 2014-10-10 13:27 編輯 + u+ a8 F/ Z- z2 l' x, {! X3 _
4 E4 Q0 N" r3 r) N* i5 _; ]
是這樣的,我剛學php的curl,想模擬登陸獲取:http://222.88.107.92/exam/xslogin.jsp' C8 N& H7 Z" c
登陸學號是:2012311032 大家可以幫我試一下。
' p2 d7 t4 s* j: @9 Q" F7 I( C$ X% \5 i% \
問題是,我訪問這個文件時候,總是提示我無效的學號信息。代碼我用來登陸php100論壇就可以,怎麼在這不行?+ ? r! O4 N& @" M( s
[mw_shl_code=php,true]<?php
7 h+ h/ W( F9 K$cookie_file = tempnam(*./temp*,*cookie*);& l$ o# q: C8 b2 m0 |! S
$login_url = *http://222.88.107.92/exam/xslogin.jsp*; //這裡沒有【url】一發貼就自己戴上了2 H+ S) L, c& ?" W+ O
$post_fields = *logname=2012311032*;
9 @( A7 s0 x9 H5 L
6 | c- s% S6 _+ A: `8 q$ch = curl_init($login_url);: L0 l; p1 M$ e" \: a4 M
curl_setopt($ch,CURLOPT_HEADER,0);
2 `. s3 h! I* X% v6 }curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
0 i& [, I2 x v% T8 q5 t1 P( Acurl_setopt($ch,CURLOPT_POST,1);
; i' S0 T/ e) `" l) V* I5 c- Vcurl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
: D+ ?* j+ u* u2 G8 K9 Scurl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
& q! K o: r q% L/ H; u* }; K# Pcurl_exec($ch);2 Y& E6 P- l4 K8 Y, x7 v
curl_close($ch);
6 F( t2 C& g {6 u t: _$ u7 k! c& n5 ~5 p" u( x1 }
$url=*http://222.88.107.92/exam/query/query.jsp*; //這裡沒有【url】一發貼就自己戴上了$ o, @$ f* U8 E! I7 ^# N
$ch = curl_init($url);
: S$ {5 \( ~* t& Z/ _: Z: E" _ ]curl_setopt($ch,CURLOPT_HEADER,0);
+ C7 D: j( z$ J. M+ e5 Bcurl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
$ }* Y8 [9 E. }' w! mcurl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file);
% o3 v0 g7 W. z# Q1 W7 ], w, k$contents=curl_exec($ch);
6 l; r6 O# {. kcurl_close($ch);
9 I: h, Z( R2 S1 t* s?>[/mw_shl_code]; V1 l9 c* ]9 A2 D' V4 y( l) ]
* g; d7 ~0 A- r$ x, r K
- _3 ^" i+ ~' F( p3 Y. j" l; P1 S問了貼吧,csdn好多地方,都沒有答案。我急著要弄一個微信查成績的訂閱號,就搜索教程,臨時學了下php的curl功能,不知道tgl的親們懂這個嗎
5 v$ T$ |% q5 c8 Y
7 K; U* P! |. ]7 L2 |- s
) N- A( y/ X; @; ?/ @0 ~& w( k1 i6 I2 K
3 f! j1 G: Q6 V! U" y
1 ?& @# Q* X* Z3 A) q+ \3 F t$ B* Y0 {! i6 c
6 ]) X8 U( ~9 q$ C d* c
! @) e/ g$ Q" y/ c+ i4 ?( ^, H5 M0 o9 s1 j& B( L6 b
|