


Detailed explanation of the usage of PHP extension CURL_PHP tutorial
Jul 13, 2016 am 10:24 AM
Function implemented:
1. Realize remote acquisition and collection of content
2. Implement FTP upload and download of PHP web version
3. Implement simulated login: go to an email system, curl can simulate cookies
4. Implement interface docking (API), data transmission, etc.: send text messages through a platform, capture and transmit the transmitted information.
5. Implement simulated cookies, etc.: Some attributes can only be operated when logged in.
How to use the CURL function :
By default, PHP does not support CURL, you need to enable this function in php.ini
;Remove the semicolon in front of extension=php_curl.dll
1 The first step in the entire operation process is to initialize with the cur_init() function
1 |
|
2. Use curl_setopt() function to set options.
3. After setting, execute the transaction curl_exec($curl);
4 Finally close curl_close();
Use PHP CURL to implement transmission and acquisition functions (post transmission method): obtain remote web page data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The most basic part of realizing remote simulated login.
curl still needs to configure the username and password, but it is hidden by the browser.
================================================== =============================
curl simulated login
Simulated login: You can still view the corresponding information even without logging into the php100 forum.
Analyze login fields--->Keep cookies after logging in-->Read cookies and jump to relevant pages--->Crawling count
1. Create a file to save the cookie content after simulating login
2. Simulate user login status by reading the generated cookie content
3. Go to relevant pages to get the content you need
tempname creates a temporary file
The tempnam() function creates a temporary file with a unique file name. If successful, the function returns the new temporary file name. On failure, returns false.
tempnam(dir,prefix)
Parameter Description
dir required. Specifies the directory where temporary files are created.
prefix required. Specifies the beginning of the file name.
Equivalent to, fopen fwirte fclose
It can return a boolean value. It is very dangerous to use a third party to log in to your QQ and msn, because it can record your login status and capture your username and password.
Use CURL to simulate logging in to the PHP100 forum
1. Analyze the field names and number of required fields in the input box required for login
2. Save cookies and obtain the number of member gold coins after simulating login
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

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

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
