You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
53 lines
1.4 KiB
3 years ago
|
<?php
|
||
3 years ago
|
/*
|
||
|
* @Author: witersen
|
||
|
* @Date: 2022-04-24 23:37:05
|
||
|
* @LastEditors: witersen
|
||
3 years ago
|
* @LastEditTime: 2022-05-06 15:37:53
|
||
3 years ago
|
* @Description: QQ:1801168257
|
||
|
*/
|
||
3 years ago
|
|
||
3 years ago
|
/**
|
||
|
* 通用请求
|
||
|
*/
|
||
3 years ago
|
function FunCurlRequest($url)
|
||
3 years ago
|
{
|
||
|
//初始化
|
||
|
$curl = curl_init();
|
||
|
|
||
|
//设置请求url
|
||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||
|
|
||
|
//设置true会将头文件的信息作为数据流输出 否则作为字符串输出
|
||
|
curl_setopt($curl, CURLOPT_HEADER, false);
|
||
|
|
||
|
//设置true会不输出body部分 此时请求类型被转变为head请求
|
||
|
curl_setopt($curl, CURLOPT_NOBODY, false);
|
||
|
|
||
|
//设置true会将curl_exec()获取的信息以字符串返回 否则会直接输出
|
||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||
|
|
||
|
//设置true会在页面发生301或者302时自动进行跳转抓取
|
||
|
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||
|
|
||
|
//将请求类型改为get 如果为探测状态 可避免因为请求类型为head造成的探测失误
|
||
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
|
||
|
|
||
|
//设置请求超时时间
|
||
3 years ago
|
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
|
||
3 years ago
|
|
||
|
//设置false将不检查证书
|
||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||
|
|
||
|
//设置false将不检查证书
|
||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||
|
|
||
|
//执行
|
||
|
$result = curl_exec($curl);
|
||
|
|
||
|
//关闭
|
||
|
curl_close($curl);
|
||
|
|
||
|
return $result;
|
||
|
}
|