Home > Backend Development > PHP Tutorial > PHP uses curl to add cookies to forge login and capture data, curlcookie_PHP tutorial

PHP uses curl to add cookies to forge login and capture data, curlcookie_PHP tutorial

WBOY
Release: 2016-07-12 08:55:32
Original
872 people have browsed it

php uses curl to add cookies to forge login and capture data. curlcookie

This article describes the example of php adding cookies to curl to forge login and capture data. Share it with everyone for your reference, the details are as follows:

Some web pages must be logged in to see. At this time, if you want to capture the information, you must pass the cookie value in the header to obtain it

1. First log in to the website, open firebug and you will see the corresponding cookies. Copy these cookies and you can use them

2,

<&#63;php
header("Content-type:text/html;Charset=utf8");
$ch =curl_init();
curl_setopt($ch,CURLOPT_URL,'http://www.babytree.com/user/picjournal.php');
$header = array();
//curl_setopt($ch,CURLOPT_POST,true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_COOKIE,'B=115.100.62.7.1401937092035530; bdshare_firstime=1401937092199; __myutma=122328856.1548793539.1401937093.1408503164.1408694138.69;');
$content = curl_exec($ch);
echo "<pre class="brush:php;toolbar:false">";print_r(curl_error($ch));echo "
"; echo "
";print_r(curl_getinfo($ch));echo "
"; echo "
";print_r($header);echo "
"; echo "
",$content;
Copy after login

Readers who are interested in more PHP related content can check out the special topics of this site: "php curl usage summary", "PHP operation and operator usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial" ", "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "Introduction to PHP object-oriented programming tutorial", "Summary of PHP string (string) usage" , "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • How to obtain COOKIE using CURL without relying on COOKIEJAR
  • How to generate a cookie file when PHP reads CURL to simulate login
  • Example of php using curl to store cookies
  • curl does not use file access cookies Example of php using curl to get cookies
  • PHP CURL method of getting cookies to simulate login
  • PHP Curl implements get, post and cookie (example introduction)
  • Introduction and promotion of php curl to crawl web pages and integration method of using CURL to crawl Taobao pages
  • php combined with curl to achieve multi-threaded crawling
  • PHP uses CURL to implement multi-threaded web crawling
  • PHP curl grabbing AJAX asynchronous content example

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1117034.htmlTechArticlephp method of adding cookies through curl to forge login and capture data, curlcookie This article tells the example of php adding cookie forgery through curl How to log in and capture data. Share it with everyone for your reference...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template