


CURL technology in PHP simulates login and captures website information, and uses it to query results on WeChat public platform_PHP tutorial
With the popularity of WeChat, the WeChat public platform has become the next target for many developers. The author himself is not so attracted to this new thing. But recently, a friend helped develop a score query function on the WeChat public platform. So I did some research in my spare time.
The main implementation steps are to simulate logging into the target website through PHP's CURL technology, obtain the user's performance information through the logged-in user, use regular expressions to capture and store the data, and use HTML technology to reconstruct the data. Do the typesetting.
The function of the WeChat public platform is to query scores through browsing. The overall technical implementation lies in PHP's CURL technology. Let’s just find a file and get the results. The specific code is as follows.
<span <</span><span HTML</span><span ></span> <span <</span><span HEAD</span><span ><</span><span TITLE</span><span ></span>请您登录<span </</span><span TITLE</span><span ></span> <span <</span><span script </span><span language</span><span ="JavaScript"</span><span ></span> <span function</span><span Judge() { </span><span var</span><span WebUserNO</span><span =</span><span document.all[</span><span "</span><span WebUserNO</span><span "</span><span ].value; </span><span if</span><span (WebUserNO</span><span ==</span><span ""</span><span ) {alert(</span><span "</span><span 登录用户不能为空!</span><span "</span><span ); document.all[</span><span "</span><span WebUserNO</span><span "</span><span ] .focus(); </span><span return</span> <span false</span><span ; } } </span><span </</span><span script</span><span ></span> <span <</span><span META </span><span http-equiv</span><span =Content-Type </span><span content</span><span ="text/html; charset=gb2312"</span><span ></span> <span <</span><span STYLE </span><span type</span><span =text/css</span><span ></span><span TD </span><span {</span><span FONT-SIZE</span><span :</span><span 12px </span><span }</span><span p1 </span><span {</span><span FONT-SIZE</span><span :</span><span 12px </span><span }</span><span INPUT </span><span {</span><span FONT-SIZE</span><span :</span><span 12px </span><span }</span><span p2 </span><span {</span><span FONT-SIZE</span><span :</span><span 12px</span><span ;</span><span LINE-HEIGHT</span><span :</span><span 14pt </span><span }</span><span p3 </span><span {</span><span FONT-SIZE</span><span :</span><span 14px </span><span }</span><span p4 </span><span {</span><span FONT-SIZE</span><span :</span><span 14px</span><span ;</span><span LINE-HEIGHT</span><span :</span><span 14pt </span><span }</span><span p5 </span><span {</span><span FONT-SIZE</span><span :</span><span 16px </span><span }</span><span p6 </span><span {</span><span FONT-SIZE</span><span :</span><span 14px</span><span ;</span><span LINE-HEIGHT</span><span :</span><span 180% </span><span }</span><span p7 </span><span {</span><span FONT-SIZE</span><span :</span><span 12px</span><span ;</span><span COLOR</span><span :</span><span #136792</span><span ;</span><span LINE-HEIGHT</span><span :</span><span 160% </span><span }</span><span BIG </span><span {</span><span FONT-SIZE</span><span :</span><span 18px </span><span }</span><span A:link </span><span {</span><span COLOR</span><span :</span><span #0000ff </span><span }</span><span A:visited </span><span {</span><span COLOR</span><span :</span><span #0000ff </span><span }</span><span A:hover </span><span {</span><span COLOR</span><span :</span><span #ff0000 </span><span }</span><span hand </span><span {</span><span CURSOR</span><span :</span><span hand</span><span ;</span><span BACKGROUND-COLOR</span><span :</span><span rgb(208,207,192) </span><span }</span> <span </</span><span STYLE</span><span ></span> <span <!--</span><span style end</span><span --></span> <span <</span><span META </span><span content</span><span ="MSHTML 6.00.2600.0"</span><span name</span><span =GENERATOR</span><span ></</span><span HEAD</span><span ></span> <span <</span><span BODY </span><span bgColor</span><span =#ffffff </span><span topMargin</span><span =7 </span><span marginheight</span><span ="0"</span><span marginwidth</span><span ="25"</span><span ></span> <span <</span><span form </span><span name</span><span ="LoginForm"</span><span method</span><span ="post"</span><span action</span><span ="qing.php"</span><span ></span> <span <</span><span TABLE </span><span cellSpacing</span><span =0 </span><span cellPadding</span><span =0 </span><span width</span><span ="100%"</span><span border</span><span =0</span><span ></span> <span <</span><span TBODY</span><span ></span> <span <</span><span TR</span><span ></span> <span <</span><span TD </span><span bgColor</span><span =#e6e6e6 </span><span height</span><span =20</span><span ></</span><span TD</span><span ></span> <span <</span><span TD </span><span align</span><span =right </span><span bgColor</span><span =#e6e6e6</span><span ></span><span </span><span </</span><span TD</span><span ></span> <span </</span><span TR</span><span ></</span><span TBODY</span><span ></</span><span TABLE</span><span ><</span><span BR</span><span ></span> <span <</span><span TABLE </span><span cellSpacing</span><span =0 </span><span cellPadding</span><span =1 </span><span width</span><span =492 </span><span align</span><span =center </span><span border</span><span =0</span><span ></span> <span <</span><span TBODY</span><span ></span> <span <</span><span TR</span><span ></span> <span <</span><span TD</span><span ></span> <span <</span><span TABLE </span><span borderColor</span><span =#c1eaff </span><span cellSpacing</span><span =0 </span><span cellPadding</span><span =20 </span><span width</span><span =474 </span><span align</span><span =center </span><span border</span><span =1</span><span ></span> <span <</span><span TBODY</span><span ></span> <span <</span><span TR</span><span ></span> <span <</span><span TD</span><span ><</span><span TABLE </span><span width</span><span =283 </span><span height</span><span ="100"</span><span border</span><span =0 </span><span align</span><span =center </span><span cellPadding</span><span =0 </span><span cellSpacing</span><span =0</span><span ></span> <span <</span><span tr</span><span ></span> <span <</span><span td </span><span width</span><span ="50"</span><span rowspan</span><span ="4"</span><span ></span><span </span><span </</span><span td</span><span ></span> <span <</span><span td </span><span align</span><span ="left"</span><span ></span> <span </</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span <</span><span tr</span><span ></span> <span <</span><span td </span><span height</span><span ="22"</span><span align</span><span ="left"</span><span ></span><span 用户名: </span><span <</span><span input </span><span name</span><span ="WebUserNO"</span><span type</span><span ="text"</span><span id</span><span ="WebUserNO"</span><span size</span><span ="12"</span><span ></</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span <</span><span tr</span><span ></span> <span <</span><span td </span><span height</span><span ="22"</span><span align</span><span ="left"</span><span ></span>密<span </span><span 码: </span><span <</span><span input </span><span name</span><span ="Password"</span><span type</span><span ="password"</span><span id</span><span ="Password"</span><span size</span><span ="12"</span><span ></</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span <</span><span tr</span><span ></span> <span <</span><span td </span><span height</span><span ="22"</span><span align</span><span ="left"</span><span valign</span><span ="middle"</span><span ><</span><span p</span><span ></span><span 附加码: </span><span <</span><span input </span><span name</span><span ="Agnomen"</span><span type</span><span ="text"</span><span id</span><span ="Agnomen"</span><span size</span><span ="12"</span><span ></span> <span </</span><span p</span><span ></span> <span <</span><span p</span><span ><</span><span A </span><span href</span><span ="User_JSP/FuJiaMa.htm"</span><span target</span><span ="_blank"</span> <span ><</span><span img </span><span src</span><span ="http://218.61.108.163/ACTIONVALIDATERANDOMPICTURE.APPPROCESS"</span><span width</span><span ="60"</span><span height</span><span ="20"</span><span alt</span><span ="验证码说明"</span><span border</span><span ="0"</span><span ></</span><span a</span><span ></</span><span p</span><span ></</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span <</span><span tr </span><span align</span><span ="center"</span><span ></span> <span <</span><span td </span><span colspan</span><span ="2"</span><span ><</span><span input </span><span type</span><span ="image"</span><span border</span><span ="0"</span><span name</span><span ="submit"</span><span src</span><span ="http://218.61.108.163/User_JSP/images/Logon.gif"</span><span width</span><span ="37"</span><span height</span><span ="18"</span><span onClick</span><span ="javascript:return Judge();"</span><span ></span> <span </</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span <</span><span tr</span><span ></span> <span <</span><span td </span><span colspan</span><span ="2"</span><span ><</span><span div </span><span align</span><span ="center"</span><span ><</span><span input </span><span name</span><span ="applicant"</span><span type</span><span ="hidden"</span><span value</span><span ="ACTIONQUERYSTUDENTSCORE"</span><span ></</span><span div</span><span ></</span><span td</span><span ></span> <span </</span><span tr</span><span ></span> <span </</span><span TABLE</span><span ></span> <span <</span><span br</span><span ></span> <span </</span><span TD</span><span ></span> <span </</span><span TR</span><span ></span> <span </</span><span TABLE</span><span ></</span><span TD</span><span ></</span><span TR</span><span ></</span><span TBODY</span><span ></</span><span TABLE</span><span ></span> <span </</span><span form</span><span ></span> <span <</span><span BR</span><span ></span> <span <</span><span BR</span><span ></span> <span </</span><span BODY</span><span ></</span><span HTML</span><span ></span>
qing.php
<?<span php </span><span $cookie_file</span> = <span tempnam</span>('./temp','cookie'<span ); </span><span $login_url</span> = 'http://218.61.108.163/ACTIONQUERYSTUDENTSCORE.APPPROCESS'<span ; </span><span $post_fields</span> = 'WebUserNO=stuid&Password=passwd&Agnomen=code&applicant=ACTIONQUERYGRADUATESCHOOLREPORTBYSELF'<span ; </span><span $ch</span> = curl_init(<span $login_url</span><span ); curl_setopt(</span><span $ch</span>, CURLOPT_HEADER, 0<span ); curl_setopt(</span><span $ch</span>, CURLOPT_RETURNTRANSFER, 1<span ); curl_setopt(</span><span $ch</span>, CURLOPT_POST, 1<span ); curl_setopt(</span><span $ch</span>, CURLOPT_COOKIEJAR, <span $cookie_file</span><span ); curl_setopt(</span><span $ch</span>, CURLOPT_POSTFIELDS, <span $post_fields</span><span ); curl_exec(</span><span $ch</span><span ); curl_close(</span><span $ch</span><span ); </span><span $url</span>='http://218.61.108.163/ACTIONQUERYGRADUATESCHOOLREPORTBYSELF.APPPROCESS'<span ; </span><span $ch</span> = curl_init(<span $url</span><span ); curl_setopt(</span><span $ch</span>, CURLOPT_HEADER, 0<span ); curl_setopt(</span><span $ch</span>, CURLOPT_RETURNTRANSFER, 0<span ); curl_setopt(</span><span $ch</span>, CURLOPT_COOKIEFILE, <span $cookie_file</span><span ); </span><span $contents</span> = curl_exec(<span $ch</span><span ); </span><span //</span><span 正则表达式提取数据。</span> <span $match</span>="|(<=<td>).*(?=</td>)|"<span ; </span><span preg_match_all</span>(<span $match</span>,<span $contents</span>,<span $b</span><span ); </span><span $abc</span> = <span $b</span>[0<span ]; </span><span $abs</span> = <span $b</span>[1<span ]; </span><span $abd</span> = <span $b</span>[1<span ]; </span><span echo</span> <span $abc</span><span ; </span><span echo</span> <span $abs</span><span ; </span><span echo</span> <span $abd</span><span ; curl_close(</span><span $ch</span><span ); </span>?>
Interface for obtaining results

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

The combination of Vue.js and ASP.NET provides tips and suggestions for performance optimization and expansion of web applications. With the rapid development of web applications, performance optimization has become an indispensable and important task for developers. As a popular front-end framework, Vue.js combined with ASP.NET can help us achieve better performance optimization and expansion. This article will introduce some tips and suggestions, and provide some code examples. 1. Reduce HTTP requests The number of HTTP requests directly affects the loading speed of web applications. pass

How to correctly use and optimize the MySQL connection pool in ASP.NET programs? Introduction: MySQL is a widely used database management system that features high performance, reliability, and ease of use. In ASP.NET development, using MySQL database for data storage is a common requirement. In order to improve the efficiency and performance of database connections, we need to correctly use and optimize the MySQL connection pool. This article will introduce how to correctly use and optimize the MySQL connection pool in ASP.NET programs.

Translator | Reviewed by Chen Jun | Chonglou In the 1990s, when people mentioned software programming, it usually meant choosing an editor, checking the code into the CVS or SVN code base, and then compiling the code into an executable file. Corresponding integrated development environments (IDEs) such as Eclipse and Visual Studio can integrate programming, development, documentation, construction, testing, deployment and other steps into a complete software development life cycle (SDLC), thus improving the work of developers. efficiency. In recent years, popular cloud computing and DevSecOps automation tools have improved developers' comprehensive capabilities, making it easier for more enterprises to develop, deploy and maintain software applications. Today, generative AI is the next generation development

How to reconnect to MySQL in ASP.NET program? In ASP.NET development, it is very common to use the MySQL database. However, due to network or database server reasons, the database connection may sometimes be interrupted or time out. In this case, in order to ensure the stability and reliability of the program, we need to re-establish the connection after the connection is disconnected. This article will introduce how to reconnect MySQL connections in ASP.NET programs. To reference the necessary namespaces first, reference them at the head of the code file

The combination of Vue.js and ASP.NET enables the development and deployment of enterprise-level applications. In today's rapidly developing Internet technology field, the development and deployment of enterprise-level applications has become more and more important. Vue.js and ASP.NET are two technologies widely used in front-end and back-end development. Combining them can bring many advantages to the development and deployment of enterprise-level applications. This article will introduce how to use Vue.js and ASP.NET to develop and deploy enterprise-level applications through code examples. First, we need to install

How to correctly configure and use MySQL connection pool in ASP.NET program? With the development of the Internet and the increase in data volume, the demand for database access and connections is also increasing. In order to improve the performance and stability of the database, connection pooling has become an essential technology. This article mainly introduces how to correctly configure and use the MySQL connection pool in ASP.NET programs to improve the efficiency and response speed of the database. 1. The concept and function of connection pooling. Connection pooling is a technology that reuses database connections. At the beginning of the program,

The built-in objects in ASP.NET include "Request", "Response", "Session", "Server", "Application", "HttpContext", "Cache", "Trace", "Cookie" and "Server.MapPath": 1. Request, indicating the HTTP request issued by the client; 2. Response: indicating the HTTP response returned by the web server to the client, etc.

Overview of the recommended configuration for using Visual Studio for ASP.NET development on Linux: With the development of open source software and the popularity of the Linux operating system, more and more developers are beginning to develop ASP.NET on Linux. As a powerful development tool, Visual Studio has always occupied a dominant position on the Windows platform. This article will introduce how to configure VisualStudio for ASP.NE on Linux
