How PHP uses curl to get data through proxies _php tips

Source: Internet
Author: User
Tags curl php code php programming php regular expression

This article is an example of how PHP uses curl to get data through proxies. Share to everyone for your reference, specific as follows:

$curl =curl_init ();
curl_setopt ($curl, Curlopt_url, "http://www.baidu.com/");
curl_setopt ($curl, Curlopt_useragent, ' mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) gecko/20100101 firefox/20.0 ');
curl_setopt ($curl, Curlopt_referer, ' http://www.guahao.com/');
curl_setopt ($curl, Curlopt_post, true);
curl_setopt ($curl, Curlopt_postfields, Http_build_query ($param));
curl_setopt ($curl, Curlopt_returntransfer, true);
curl_setopt ($curl, Curlopt_httpproxytunnel, true);
curl_setopt ($curl, Curlopt_proxyauth, curlauth_basic);
curl_setopt ($curl, Curlopt_proxytype, CURLPROXY_SOCKS5);
curl_setopt ($curl, Curlopt_proxy, "180.186.11.121");
curl_setopt ($curl, Curlopt_proxyport, "37211");
curl_setopt ($curl, Curlopt_proxyuserpwd, "taras:taras-ss5");
$result =curl_exec ($curl);

PS: Small knitting here recommend a site for the layout of the PHP format landscaping tools to help you in the future of PHP programming code layout:

PHP Code online Format Landscaping tool:Http://tools.jb51.net/code/phpformat

More about PHP Interested readers can view the site topics: "Php Curl Usage Summary", "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Mathematical Calculation Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string (String) Usage summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.