普通网友 2015-09-11 14:54
浏览 147

PHP file_get_contents和CURL无法获取基于javascript的页面的内容

I have tried both file_get_contents and CURL to fetch the content of a specific page. I setup the CURL to follow redirects and changed User-Agent, however, it did not work. I have no problem when loading page in browser. I get a page with below code whenever I try to fetch it with file_get_contents or CURL:

 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Loading ...</title> <script 
src="/jquery.js" type="text/javascript"></script> </head> <html> <noscript>Enable java!</noscript> <div id="status"></div> <script type="text/javascript"> 
function check(){ $.ajax({
    type: "POST",
    url: "/index.php",
    data: "allowed=5b91b80a061537ae6a23835aba38279e",
    success: function(html){if(html == "allowed"){location.reload();}},
    beforeSend:function(){
        $("#status").html("Loading ...")
    }
});
}
$(document).ready(function(){
    check();
});
</script> </html> 

Is there anyway to bypass such restriction without using Javascript based Web Scrapers like PhantomJs, CasperJs or ZombieJs? Simply using a plain PHP?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ensp的问题(需要各个路由器命令)
    • ¥15 Matlab怎么求解含参的二重积分?
    • ¥15 苹果手机突然连不上wifi了?
    • ¥15 cgictest.cgi文件无法访问
    • ¥20 删除和修改功能无法调用
    • ¥15 kafka topic 所有分副本数修改
    • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
    • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
    • ¥40 串口调试助手打开串口后,keil5的代码就停止了
    • ¥15 电脑最近经常蓝屏,求大家看看哪的问题