我需要从aspx站点获取完整的输出。当用户离开时,我将保存cookie中某些特定元素的内容。问题是aspx位于我无权访问的域上。我希望输出的行为就像在iframe中一样,因此链接需要是可单击的,但它不会离开我的页面。

我想到的是带有PHP代理的AJAX或我可以在其中修改内容的iframe。
这可能吗?
如果可能并且涉及服务器端代码,我想知道是否有任何支持完整代码的免费Web主机(例如,几乎每个免费Web主机都为PHP启用了safe_mode)。

编辑:我想显示此页面:School scheme。 URL不会改变,它只是将请求发送到服务器(通过JavaScript来考虑)。当用户离开时,我将看到选择框id =“ TypeDropDownList”中的内容以及选择框id =“ ScheduleIDDropDownList”中的内容。

当用户返回我的页面时,我将通过类似"http://www.novasoftware.se/webviewer/(S(lv1isca2txx1bu45c3kvic45))/design1.aspx?schoolid=27500&code=82820&type=" + type + "&id=" + id + "的URL将这些值打印到页面上

我在这里发布之前在000webhost上尝试了几种php代理脚本。
例如:

<?php
ob_start();

function logf($message) {
  $fd = fopen('proxy.log', "a");
  fwrite($fd, $message . "\n");
  fclose($fd);
}

?>
<?
$url = $_REQUEST['url'];
logf($url);
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, "Owen's AJAX Proxy");

$content = curl_exec($curl_handle);
$content_type = curl_getinfo($curl_handle, CURLINFO_CONTENT_TYPE);
curl_close($curl_handle);
header("Content-Type: $content_type");
echo $content;
ob_flush();
?>


但它返回警告:curl_setopt():提供的参数不是/home/a5379897/public_html/ajax-proxy.php第16行中的有效cURL句柄资源

我试图与他们联系,因为他们说他们已经启用了cURL,但还没有响应。

我认为有可能在用户首次访问该页面时仅显示两个选择框。选择选项后,它将通过传递“ http://www.novasoftware.se/webviewer/(S(lv1isca2txx1bu45c3kvic45))/design1.aspx?schoolid=27500&code=82820&type=“ + type +”使iframe显示正确的页面&id =“ + id +”设置为src属性。
这样做的问题是,我将需要检索选择框,而我将遇到相同的问题。

最佳答案

要将整个aspx输出作为字符串进行操作,可以使用file_get_contents(http://yoursite.com/yourpage.aspx);

为了获得最佳结果,请通过http打开流作为上下文。

<?php
// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en\r\n" .
              "Cookie: foo=bar\r\n"
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.example.com/', false, $context);
?>

关于php - 获取html跨站点,将其显示并获取元素值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4392520/

10-12 12:52
查看更多