2016-09-11 7 views
-5

사용자가 값을 가져 와서 $ html = file_get_html ('')에 입력하고 페이지의 출력 값을 에코하는 양식 텍스트 상자에 값을 입력하게합니다.HTML 입력의 PHP 출력 양식

<form action="dex.php" method="POST"> 
<b>Site:</b><input type="text" name="site" /> 
<input type="submit" name="submit" value="Search" /> 
</form> 

<?php 
include('simple_html_dom.php'); 

$html = str_get_html('site'); 
echo htmlspecialchars($_POST['site']); 
$html->find('div', 1)->class = 'bar'; 
$html->find('div[id=site]', 0)->innertext = 'foo'; 
//echo $html; here doesn't show webpage just results 
$html = file_get_html('http://www.myrobotbuddy.com'); 
//$html - file_get_html(' '); from form input 
echo file_get_html('$html')->plaintext; 
echo $html; //shows website also 
?> 
+1

귀하 질문이 명확하지 않고 무엇을하기 위해 당신이 쟁점이되는지 말하지 마십시오 – xzegga

답변

0

난 단지 당신이 무엇을 달성하고자하는 추측 만 해요 :

먼저 변수에 양식 입력을받을 :

if (isset($_POST['submit'])) { 
    $site = htmlspecialchars($_POST['site']); 
} 

다음 :

if(isset($site)){ 
    $html = str_get_html($site); 
} 
+0

고맙습니다. 나는 그 질문에 대해 어떻게해야할지 모르겠다. 사용자가 입력 상자에 http 주소를 입력 한 다음 크롤링 결과를 게시하십시오. 최소한 모든 질문을 저격하기를 원하는 수많은 싫어하는 사람들보다 적어도 기회를 더 많이 주셔서 감사합니다. 고맙습니다 Stoycho :) –