Home >Backend Development >PHP Tutorial >PHP中使用CURL伪造来路抓取页面或文件_php技巧

PHP中使用CURL伪造来路抓取页面或文件_php技巧

WBOY
WBOYOriginal
2016-05-17 09:19:41938browse
复制代码 代码如下:

// 初始化
$curl = curl_init();
// 要访问的网址
curl_setopt($curl, CURLOPT_URL, 'http://asen.me/');
// 设置来路
curl_setopt($curl, CURLOPT_REFERER, 'http://google.com/');
// 不直接输入内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// 降结果保存在$result中
$result = curl_exec($curl);
// 关闭
curl_close($curl);

注意啦, 使用这个方法, 要确保你的 PHP 环境支持并且开启了 CURL 模块.
Statement:
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