Home > headlines > PHP crawls HTTPS website content

PHP crawls HTTPS website content

PHP中文网
Release: 2017-12-15 11:34:55
Original
4228 people have browsed it

Unlike the ordinary HTTP protocol, when using the function file_get_contents() in PHP to obtain the data provided in the API, an error will occur.

This is because there is no parameter enabled in the PHP configuration file. On my local computer, it is the;extension=php_openssl.dll item in /apache/bin/php.ini. You need to change the previous Remove the semicolon. You can use the following script to check the configuration of your PHP environment:

PHP crawls HTTPS website content

##The output is as follows:

640 (1).jpg

If you are using a remote host and cannot modify the configuration,

Another commonly used function to capture content in PHP is curl. It is more powerful than file_get_contents() and provides a lot of optional parameters. For the problem of accessing HTTPS content, the CURL configuration parameters we need to use are:

640 (2).jpg

It can be understood from the semantics, it is ignore/skip SSL security verification.

The following is a function encapsulated by Curl that can access HTTPS content:


##

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