0

我已经尝试过这种方式(根据“jerjer”的选择答案)但未能加载内容..

加载外部网站的内容

render.php

<?php
    $url = 'http://apps.irs.gov/app/withholdingcalculator/index.jsp';
    $htm = file_get_contents($url);
    echo $htm;
?>

common.js

$(document).ready(function(){
    $('#divId').load('render.php');
});

index.html

<html>
<head>
    <title>Home</title>
    <link rel="stylesheet" href="css/style.css" type="text/css">
    <script src="js/jquery.js"></script>
    <script src="js/common.js"></script>
</head> 
<body>
    <div id="divId"></div>
</body>
</html>

有什么帮助吗?提前致谢...

4

1 回答 1

1

使用此代码。确保安装了 curl 扩展。

 $url = 'http://apps.irs.gov/app/withholdingcalculator/index.jsp';
 $htm = getCurlData($url);
 echo $htm;

function getCurlData($url)
{
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $contents = curl_exec($ch);
     curl_close($ch);
     return $contents;
}
于 2013-09-29T18:41:28.443 回答