0

我有一个网站,我想从那个网站下载iframe包含。

那是

<iframe frameborder="no" align="center" width="100%" height="500px" style="width: 100%; height: 500px" name="FRAME1" src="/CWRWeb/nova/jsp/reports/running.jsp"></iframe>

在此 iframe 中存在数据。

使用PHP Scriptable Web Browser我能够获得该页面。但我无法访问 iframe 数据。

所以我尝试了这个,但我没有。

这是我的代码:

<?php
require_once('simpletest/browser.php');

$browser = new SimpleBrowser();
$browser->get('https://www.mywebsite.com');
$browser->setField('userID', 'abc');
$browser->setField('passwd', 'abc123');
$log=$browser->click('login');





$browser->setCookie('xx','12345'); 
$browser->setCookie('pqr','dsw1278');

echo $log; /* suceessful login */

/* next page which has paremeter to be set */
$parameters = array (
"fromMonth"=>"NOV",
"fromDay"=>"05",
"fromYear"=>"2013",
"toMonth"=>"NOV",
"toDay"=>"05",
"toYear"=>"2013",

);


$browser->post('https://www.xxxx.com/Web/download.do?',$parameters); /*page where iframe is present */

/* here i want to access my iframe so i used */

$ch = curl_init(); 

        // Set url and other options
        curl_setopt($ch, CURLOPT_URL,"/CWRWeb/nova/jsp/reports/running.jsp");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // Get the page contents
        $output = curl_exec($ch); 

        echo $output;

        // close curl resource to free up system resources 
        curl_close($ch);  

?>

谁能告诉我获取 iframe 数据的最佳方式。

4

1 回答 1

0

您可以尝试 PHP 中的 get 选项。

<?php
$data = $_GET['YOUR_IFRAME_URL'];
// OR
$data = file_get_contents('YOUR_IFRAME_URL');

echo $data; //string output
?>
于 2013-11-12T09:47:01.553 回答