扫码关注官方订阅号
http://www.mayishebao.com/shebao 用file_get_contents为什么不能抓取
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
php.ini中allow_url_fopen是否开启
echo file_get_contents(); 不要赋值直接echo出来,如果有数组,就是没有转类型导致的!
$html = file_get_contents($url); $html = iconv("gb2312", "utf-8//IGNORE",$html); echo $html;
获取本地内容可用file_get_contents, 获取外部内容推荐用curl,推荐用curl
file_get_contents
curl
参看之前的回答php file_get_contents 不能获得内容
ps:提问前最好搜索下相关问题
有些是有防爬虫策略的啊,需要设置header信息什么的,还是像楼上说的用curl吧
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
php.ini中allow_url_fopen是否开启
echo file_get_contents(); 不要赋值直接echo出来,如果有数组,就是没有转类型导致的!
$html = file_get_contents($url);
$html = iconv("gb2312", "utf-8//IGNORE",$html);
echo $html;
获取本地内容可用
file_get_contents, 获取外部内容推荐用curl,推荐用curl参看之前的回答php file_get_contents 不能获得内容
ps:提问前最好搜索下相关问题
有些是有防爬虫策略的啊,需要设置header信息什么的,还是像楼上说的用curl吧