Home > php教程 > php手册 > PHP中使用CURL伪造来路抓取页面或文件

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

WBOY
Release: 2016-06-06 20:36:55
Original
785 people have browsed it

这个是用 PHP 伪造来路, 抓取文件或页面的代码, 挺简单的.

代码如下:
// 初始化
$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 模块.
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template