


Example of php using curl to simulate logging in and collecting pages_PHP tutorial
The homework I received today is to obtain product inventory from a website, but this website requires login. I used fsockopen to pass the entire header to no avail, so I had to resort to curl.
By the way, let me talk about how to open the curl module:
(1) Copy: libeay32.dll, ssleay32.dll from the php directory to the windows directory.
(2) Open php.ini, search for "extension_dir = xxxxx", and confirm that there is a php_curl.dll file in the following file directory.
(3) The same is php.ini, look for "extension=php_curl.dll" and confirm that it is not commented (there is no ';' in front).
(4) Restart apache. If an error message appears when using the curl_init(); statement, it means the installation was not successful.
$curl = curl_init();
$cookie_jar = tempnam('./ tmp','cookie');
curl_setopt($curl, CURLOPT_URL,'http://b2b.bookuu.com/b2b_club/checkUser.jsp');//Write the login interface here
curl_setopt ($curl, CURLOPT_POST, 1);
$request = 'user=xxx&password=xxx';
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);//Transfer data
curl_setopt($curl, CURLOPT_COOKIEJAR , $cookie_jar);//Save the returned cookie information in the $cookie_jar file
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//Set whether the returned data is automatically displayed
curl_setopt($curl, CURLOPT_HEADER, false);//Set whether to display header information
curl_setopt($curl, CURLOPT_NOBODY, false);//Set whether to output page content
curl_exec($curl);//Return results
curl_close($curl); //Close
$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_URL, 'http://b2b.bookuu.com/search/b2b_zxsm_new.jsp');//Which page should you get information from after logging in
curl_setopt($curl2, CURLOPT_HEADER, false);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_COOKIEFILE, $cookie_jar);
$content = curl_exec($curl2) ;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
