0
我在與傳遞一個複雜的URL麻煩file_get_html當我嘗試這個代碼簡單DOM file_get_html返回空頁
<?php
require_once("$_SERVER[DOCUMENT_ROOT]/dom/simple_html_dom.php");
$base = $_GET['url'];
//file_get_contents() reads remote webpage content
$html_base = file_get_html("http://www.realestateinvestar.com.au/ME2/dirmod.asp?sid=1A0FFDB3E8CD48909120C118D03F6016&nm=&type=news&mod=News&mid=9A02E3B96F2A415ABC72CB5F516B4C10&tier=3&nid=C67A9DD2C0144B9EB41DB58365C05927");
foreach($html_base->find('p') as $td) {
echo $td;
}
?>
它的工作原理
但是,如果我嘗試通過URL作爲一個變量通過mysite.com/goget.php?url=http://www.realestateinvestar.com.au/ME2/dirmod.asp?sid=1A0FFDB3E8CD48909120C118D03F6016&nm=&type=news&mod=News&mid=9A02E3B96F2A415ABC72CB5F516B4C10&tier=3&nid=C67A9DD2C0144B9EB41DB58365C05927
<?php
require_once("$_SERVER[DOCUMENT_ROOT]/dom/simple_html_dom.php");
$base = $_GET['url'];
//file_get_contents() reads remote webpage content
$html_base = file_get_html($base);
foreach($html_base->find('p') as $td) {
echo $td;
}
?>
它返回一個空白頁。
任何幫助?
是否'require_once( 「$ _ SERVER [DOCUMENT_ROOT] /dom/simple_html_dom.php」);'即使你期望的工作?我會嘗試'require_once($ _ SERVER ['DOCUMENT_ROOT']。「/dom/simple_html_dom.php」);' – SyntaxTerror
不,這不是問題,代碼的第一部分與require_once(「$ _ SERVER [DOCUMENT_ROOT]/dom/simple_html_dom.php「);第二部分代碼不是 – user3664594
嘗試[urldecode()](http://www.php.net/manual/en/function.urldecode.php)你的'$ base'變量。 –