PHP curl

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 08:56:55
Original
992 people have browsed it

What is curl

curl is an open source file transfer tool that uses URL syntax to work in command line mode.

Use of PHP

Using PHP's cURL library can easily and effectively capture web pages. You only need to run a script and analyze the web pages you crawled, and then you can get the data you want programmatically. Whether you want to retrieve partial data from a link, take an XML file and import it into a database, or even simply retrieve the content of a web page, cURL is a powerful PHP library.

demo1

<code><span><span><?php</span><span>//1.初始化,创建一个新cURL资源 </span><span>$ch</span> = curl_init();
    <span>//2.设置URL和相应的选项</span>
    curl_setopt(<span>$ch</span>, CURLOPT_URL, <span>"http://www.lampbrother.net/"</span>) 
    curl_setopt(<span>$ch</span>, CURLOPT_HEADER, <span>0</span>); 
    <span>//3.抓取URL并把它传递给浏览器 </span><span>$data</span> = curl_exec(<span>$ch</span>); 
    <span>//4.显示获得的数据</span>
    var_dump(<span>$data</span>);
    <span>//5.关闭cURL资源,并且释放系统资源 </span>
    curl_close(<span>$ch</span>);
<span>?></span></span></code>
Copy after login

demo2 post data

<code>﹤?php
<span>$phoneNumber</span> = <span>'13812345678'</span>;
<span>$message</span> = <span>'This message was generated by curl and php'</span>;
<span>$curlPost</span> = <span>'pNUMBER='</span> . urlencode(<span>$phoneNumber</span>) . <span>'&MESSAGE='</span> . urlencode(<span>$message</span>) . <span>'&SUBMIT=Send'</span>;
<span>$ch</span> = curl_init();
curl_setopt(<span>$ch</span>, CURLOPT_URL, <span>'http://www.lxvoip.com/sendSMS.php'</span>);
curl_setopt(<span>$ch</span>, CURLOPT_HEADER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_POST, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_POSTFIELDS, <span>$curlPost</span>);
<span>$data</span> = curl_<span>exec</span>();
curl_close(<span>$ch</span>);
?﹥</code>
Copy after login

demo3 use proxy server

<code>﹤?php 
<span>$ch</span> = curl_init();
curl_setopt(<span>$ch</span>, CURLOPT_URL, <span>'http://www.cmx8.cn'</span>);
curl_setopt(<span>$ch</span>, CURLOPT_HEADER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_HTTPPROXYTUNNEL, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_PROXY, <span>'proxy.lxvoip.com:1080'</span>);
curl_setopt(<span>$ch</span>, CURLOPT_PROXYUSERPWD, <span>'user:password'</span>);
<span>$data</span> = curl_<span>exec</span>();
curl_close(<span>$ch</span>);
?﹥</code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced PHP curl, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
curl simulated login
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Please tell me, php curl request page shows blank
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template