0
我有其他網站的一個簡單的IFrame在我的網站:獲取從一個IFrame的URL地址在我的網站使用PHP
<iframe name="frame1" src="http://www.walla.co.il" width="100%" height="400"></iframe>
網站不屬於我以任何方式。我一直在尋找方法去獲取該網站的確切URL地址 ,並將其作爲回聲發佈,以便觀衆可以在我的網站上查看該網站的地址。 我發現了一些在線腳本,但他們似乎沒有工作。
它甚至有可能做到這一點?我只是在尋找一種方式來回應它的變量(像回聲$網址;)
這是我試過到目前爲止:
<iframe name="frame1" src="http://www.walla.co.il" width="100%" height="400"></iframe>
<?php
$htmlPage = file_get_contents("http://www.walla.co.il"); //the page has the iframe
if(preg_match_all("/<iframe[^>]*name=\"frame1\"[^>]*src=\"([^\"]+)\"[^>]*>/i", $htmlPage, $matches))
{
print_r($matches);
echo $matches[1][0];
}
?>
似乎沒有工作,謝謝你的嘗試。 – user1938653
它適用於「
@ user1938653 - 您是否收到任何錯誤?嘗試取消註釋print_r語句。並查看數組的結果 – SolidSnake