Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php获取在asp.net中设计的网页内容?_Php - Fatal编程技术网

如何使用php获取在asp.net中设计的网页内容?

如何使用php获取在asp.net中设计的网页内容?,php,Php,------我试过使用htmlextension页面,它可以工作,也可以工作“http://www.cfp.net“但它会显示一条错误消息,表示抱歉,这意味着$s为空,因此$s无法在上述代码中获取任何内容。” 请帮助我获取变量$s中的内容,并将内容保存在html页面中,即使用纯php代码扩展html。我建议您在服务器上查看此内容 <?php $url='http://www.cfp.net/find/EnhancedSearch.aspx'; $s = @file_get_c

------我试过使用htmlextension页面,它可以工作,也可以工作“http://www.cfp.net“但它会显示一条错误消息,表示抱歉,这意味着$s为空,因此$s无法在上述代码中获取任何内容。”


请帮助我获取变量$s中的内容,并将内容保存在html页面中,即使用纯php代码扩展html。

我建议您在服务器上查看此内容

<?php       
$url='http://www.cfp.net/find/EnhancedSearch.aspx';
$s = @file_get_contents($url);  
    if (empty($s))
    {
    // Web page empty/access failure
        echo "sorry!";
    }
    else
    {
    echo($s);
}
?>

由于这会产生内部错误,而且您会在顶部抑制错误,所以它甚至无法报告任何错误。我建议您使用CURL,我建议您在服务器上查看此内容

<?php       
$url='http://www.cfp.net/find/EnhancedSearch.aspx';
$s = @file_get_contents($url);  
    if (empty($s))
    {
    // Web page empty/access failure
        echo "sorry!";
    }
    else
    {
    echo($s);
}
?>

由于这会产生内部错误,而且您会在顶部抑制错误,所以它甚至无法报告任何错误。我建议使用CURL,您的问题在于不要覆盖请求的默认用户代理

服务器正在拒绝PHPs默认用户代理

出于某种原因,它默认接受wget请求,但不接受PHP请求-奇怪

如果将其更改为伪造的浏览器用户代理,则该请求将生效

以下是完整的代码:

[NullReferenceException: Object reference not set to an instance of an object.]
   CertificantSearch.CFP.get_bMobile() in D:\2.0Projects\CFPBoard\Certificant\CertificantSearch\CFP.Master.cs:23
   CertificantSearch.EnhancedSearch.Page_Load(Object sender, EventArgs e) in D:\2.0Projects\CFPBoard\Certificant\CertificantSearch\EnhancedSearch.aspx.cs:151
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

您的问题在于没有覆盖请求的默认用户代理

服务器正在拒绝PHPs默认用户代理

出于某种原因,它默认接受wget请求,但不接受PHP请求-奇怪

如果将其更改为伪造的浏览器用户代理,则该请求将生效

以下是完整的代码:

[NullReferenceException: Object reference not set to an instance of an object.]
   CertificantSearch.CFP.get_bMobile() in D:\2.0Projects\CFPBoard\Certificant\CertificantSearch\CFP.Master.cs:23
   CertificantSearch.EnhancedSearch.Page_Load(Object sender, EventArgs e) in D:\2.0Projects\CFPBoard\Certificant\CertificantSearch\EnhancedSearch.aspx.cs:151
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

为什么要取消对
文件\u get\u contents()
的警告?如果删除
@
,它会发出警告吗?是的,它会发出HTTP/1.1500内部服务器错误:)为什么要抑制
文件获取内容()的警告?如果您删除
@
,它会发出警告吗?是的,它会给出带有CURL的HTTP/1.1500内部服务器错误:),它会接收响应体,而不仅仅是500个错误头啊,是的,我知道了。对于原始文件的内容代码,它只是用CURL的“HTTP/1.1500内部服务器错误”停止-它接收响应体,而不仅仅是500个错误头啊,是的,我看到了。对于原始的文件内容代码,它只是以“HTTP/1.1500内部服务器错误”停止