header("Content-type: text/html; charset=gb2312");
$CookieFile=tempnam("./tmep","beast");
if(isset($_GET["img"])){
$url = 'http://jwc.wyu.edu.cn/student/rndnum.asp';//验证码code
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//把返回来的cookie信息保存在文件中
curl_exec($ch);
curl_close($ch);
exit();
}
if(isset($_POST['d'])){
$b=$_POST['d'];//验证码
$p="UserCode=3114002555&UserPwd=不告诉你&Validate=".$b."&Submit=提 交";
$ch = curl_init();
// 2. 设置选项,包括URL
$reffer = 'http://jwc.wyu.edu.cn/student/body.htm';
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0");
curl_setopt($ch,CURLOPT_URL, "http://jwc.wyu.edu.cn/student/logon.asp");
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
$s = curl_exec($ch);
curl_close($ch);
$ch = curl_init();
$reffer = 'http://jwc.wyu.edu.cn/student/body.htm';
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0");
curl_setopt($ch,CURLOPT_URL, "http://jwc.wyu.edu.cn/student/logon.asp");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
$bs = curl_exec($ch);
echo $bs;//输出结果
curl_close($ch);
}else{
?>
}
?>
回复讨论(解决方案)
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的
怎么带上session,在哪里带上
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的
怎么带上 我学没多久,curl弄了很久了 如果可以能告诉下吗
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的
可以用curl_setopt($ch,CURLOPT_HTTPHEADER,"Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/");带上吗
$url = 'http://jwc.wyu.edu.cn/student/';print_r(get_headers($url));Array
(
[0] => HTTP/1.1 200 OK
[1] => Cache-Control: private
[2] => Connection: close
[3] => Date: Mon, 24 Aug 2015 11:30:29 GMT
[4] => Content-Length: 617
[5] => Content-Type: text/html
[6] => Set-Cookie: ASPSESSIONIDCQAATSAR=HGOCKONAKIMOPBIOFJFHPGFI; path=/
[7] => Server: IIS
[8] => X-Powered-By: WAF/2.0
[9] => Set-Cookie: safedog-flow-item=6BFDB3BC0A21C98B7224B81C2C04C934; expires=Mon, 24-Aug-2015 16:00:29 GMT; domain=wyu.edu.cn; path=/
)
访问主页就已经有 session 了,你读验证码时不带上是不行的
非常感谢 我模拟登陆成功了

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
