The functions implemented:
1. Realize remote acquisition and acquisition of content
2, the implementation of PHP Web version of the FTP upload download
3, realize the simulation landing: Go to a mail system, curl can simulate cookies
4, to achieve interface docking (API), data transmission, such as: through a platform to send text messages, crawling and transmitting the information transmitted.
5, the realization of analog cookies, etc.: the state of landing can be manipulated some properties.
How to use the Curl feature :
By default PHP does not support curl, you need to turn on this feature in php.ini
The semicolon in front of the Extension=php_curl.dll is removed
1 The first step during the entire operation is to initialize with the Cur_init () function.
$curl = Curl_init (' www.jb51.net ')
2. Set the option with the curl_setopt () function.
3. After setting, perform the transaction curl_exec ($curl);
4 finally close curl_close ();
Use PHP curl for transfer and capture (post transfer): Get Remote Web page data
$user = "admin"; $pass = "admin"; $curlPost = "user= $user &pass= $pass"; $ch = Curl_init (); Initialize a Curl object curl_setopt ($ch, Curlopt_url, "http://localhost/edu/login.php");//Set the urlcurl_setopt you need to crawl ($ch, Curlopt_returntransfer, 0);//Set the curl parameter, which requires the result to be output to the screen, true when it is not returned to the Web page if the above 0 is changed to 1, then the next $data need to echo. curl_setopt ($ch, Curlopt_post, 1);//post Submit curl_setopt ($ch, Curlopt_postfields, $curlPost); $data = Curl_exec ($ch);// Run Curl and request the Web page. Curl_close ($ch); [/code]
Realize the most basic part of remote simulation landing.
Curl also needs to configure the user name and password, but is hidden by the browser.
============================================================================
Curl Simulation Login
Analog landing: is not landing to the PHP100 forum, you can also see the corresponding information.
Analyze login Field---> Leave cookie after Login--read cookie and jump to related page--crawl count
1. Create a file after the login to save the cookie content
2. Simulate user login status by reading the generated cookie content
3, to the relevant page to obtain the required content
Tempname Creating a temporary file
The Tempnam () function creates a temporary file with a unique file name. If successful, the function returns a new temporary file name. If it fails, it 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, Fopenfwirtefclose
It can return a Boolean value. Using a third party to login to your QQ, MSN is very dangerous, because it can record your login status, crawl your user name and password.
Login to the PHP100 forum using Curl emulation
1, analyze the login required input box field name and the number of fields required
2, save the cookie simulation login to obtain the number of member coins
Code:
Initialize a Curl Object $curl = Curl_init ();//Set the urlcurl_setopt you need to crawl ($curl, Curlopt_url, "http://www.baidu.com");//Set the curl parameter, Requires the result to be saved to a string or output to the screen. curl_setopt ($curl, Curlopt_returntransfer, 0);//Run Curl, request page $data = curl_exec ($curl);//close URL request curl_close ($curl); user = "Admin"; $pass = "admin100"; $curlPost = "user= $user &pass= $pass"; $ch = Curl_init (); curl_setopt ($ch, Curlopt_ URL, "http://localhost/curl/login.php"); curl_setopt ($ch, Curlopt_returntransfer, 0); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, $curlPost), $data = Curl_exec ($ch); Curl_close ($ch);? >if ($_post[' user ']== "admin") {echo "";} else{echo "";} Print_r ($_post);? >
http://www.bkjia.com/PHPjc/825427.html www.bkjia.com true http://www.bkjia.com/PHPjc/825427.html techarticle implementation of the function: 1, to achieve remote acquisition and acquisition of Content 2, the implementation of PHP Web version of the FTP upload download 3, to achieve the simulation landing: to a mail system, curl can simulate the cookies 4, realize ...