Embed an External Page Without an Iframe?

前端 未结 6 1554
青春惊慌失措
青春惊慌失措 2020-11-28 05:04

Is there any way to embed an external web page without using an iframe? I have access to both sites, I just want the page that the content is embedded on to resize based on

6条回答
  •  抹茶落季
    2020-11-28 05:25

    What about something like this?

    ';
    $host = preg_replace('/^[^\/]+\/\//', '', $URL);
    $tarray = explode('/', $host);
    $host = array_shift($tarray);
    $URI = '/' . implode('/', $tarray);
    $content = '';
    $fp = @fsockopen($host, 80, $errno, $errstr, 30);
    if(!$fp) { echo "Unable to open socked: $errstr ($errno)\n"; exit; } 
    fwrite($fp,"GET $URI HTTP/1.0\r\n");
    fwrite($fp,"Host: $host\r\n");
    if( isset($_SERVER["HTTP_USER_AGENT"]) ) { fwrite($fp,'User-Agent: '.$_SERVER
    
    ["HTTP_USER_AGENT"]."\r\n"); }
    fwrite($fp,"Connection: Close\r\n");
    fwrite($fp,"\r\n");
    while (!feof($fp)) { $content .= fgets($fp, 128); }
    fclose($fp);
    if( strpos($content,"\r\n") > 0 ) { $eolchar = "\r\n"; }
    else { $eolchar = "\n"; }
    $eolpos = strpos($content,"$eolchar$eolchar");
    $content = substr($content,($eolpos + strlen("$eolchar$eolchar")));
    if( preg_match('//i',$content) ) { echo( preg_replace('//i',''.
    
    $base,$content,1) ); }
    else { echo( preg_replace('/<([a-z])([^>]+)>/i',"<\\1\\2>".$base,$content,1) ); }
    ?>
    

提交回复
热议问题