2012-04-10 6 views
0

텍스트 영역에 입력 한 URL의 메타 태그를 가져 오려고합니다. 무엇이 잘못 되었나요?PHP 메타 태그 가져 오기, 배열의 URL = 작동하지 않음

또한 설명과 함께 메타 설명의 URL을 어떻게 넣을까요?

<form method="get"> 
<textarea name="TAData"> 
</textarea> 
<input type="submit" value="submit"/> 
</form> 

<div id="checkboxes"> 
<input type="checkbox" name="vehicle" value="PR" /> Show me the PR<br /> 
<input type="checkbox" name="vehicle" value="KW Tag" /> Show me the KW tag<br /> 
<input type="checkbox" name="vehicle" value="Title Tag" /> Show me the Title tag<br /> 
</div> 
<div id="checkboxes"> 
<input type="checkbox" name="vehicle" value="1stH1" /> Show me the 1st H1<br /> 
<input type="checkbox" name="vehicle" value="2ndH1" /> Show me the 2nd H1 tag<br /> 
<input type="checkbox" name="vehicle" value="SeedKW" /> Show me Seed KW's<br /> 
</div> 

<div id="nofloat"></div> 

<?php 

//make the array 
$TAarray = explode("\n", strip_tags($_POST['TAData'])); 

var_dump($TAarray); 

//loop through the array 
foreach ($TAarray as $line) { 


    $line = htmlspecialchars(trim($line)); 
}  

    foreach ($TAarray as $url) { 

      // get the meta data for each url 
      $tags = get_meta_tags($url); 

unset($tags["content-type"]); 
unset($tags["page-type"]); 
unset($tags["page-topic"]); 
unset($tags["audience"]); 

       echo '<tr>'; 
       foreach ($tags['description'] as $meta)   
      { 
         echo '<td>' . $meta . '</td>'; 
       } 
       echo '</tr>'; 
     } 
?> 

또한 메타 설명 만 포함 할 수 있습니까?

+2

당신은'$ _POST를 [확인 중 'TAData']'하지만 양식 방법은'get'입니다. 'post' 여야합니다. –

+4

PHP를 처음 사용하는 경우라도 "작동하지 않는 것"이상을 알고있을 것입니다. 귀하의 질문에 약간의 노력을 기울이십시오. –

+0

의견을 주셔서 감사합니다. 정말 다른 것을 알지 못 했으므로 오류가 보이지 않았습니다 ... – RuFFCuT

답변

1

1) 양식이 GET으로 선언되었지만 $ _POST 필드에서 값을 읽는 중입니다.

2) 당신은 단지 "설명"메타 값을 추출 할 경우, 당신은 그냥 사용할 수있는 태그를 통해 반복 작업을 수행 할 필요가 없습니다 :

$description = $tags["description"] 
+0

도움을 주셔서 감사합니다! – RuFFCuT

+0

스크립트가 작동 중입니다.하지만 두 번째 줄로 가면 바로 텍스트 영역에 하나의 URL을 넣을 때만 오류가 발생합니다. ** 잘못된 인수가 foreach() ** 및 ** [function.get php_network_getaddresses : getaddrinfo 실패 : 이름 또는 서비스를 알 수 없음 ** – RuFFCuT

+0

'foreach ($ TAarray as $ key => & $ line) {$ line = trim ($ line); }' – kuba

관련 문제