侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

php 获取远程网页内容的函数

2023-12-10 星期日 / 0 评论 / 0 点赞 / 32 阅读 / 528 字

<?php $curDomain = $_SERVER['HTTP_HOST']; $strHTML = file_get_contents('https://www.jb51.net/DomainParking.asp

<?php
$curDomain = $_SERVER['HTTP_HOST'];
$strHTML = file_get_contents('https://www.jb51.net/DomainParking.asp?gDomName='.$curDomain);
echo $strHTML
?>
早就在网上看到说file_get_contents不稳定,果然碰到了。。。
另一方面也说明了程序的容错性很差啊。。。
恩,言归正传吧。
碰到的是这个错误:
file_get_contents(http://***.php): failed to open stream: HTTP request failed!
G一下,决定用curl

广告 广告

评论区