douangzhao4108 2012-04-10 16:17
浏览 24
已采纳

PHP获取Meta标签,Arrays中的URL =不工作[关闭]

I am trying to get the meta tags of the urls entered in the text area, what is wrong with this?

Also, how would I put the URL that the meta description came from with the description?

<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("
", 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>';
        }
?>

Also, is there a way to only include the meta description?

  • 写回答

1条回答 默认 最新

  • duanjiuhong5843 2012-04-10 16:24
    关注

    1) your form is declared as GET, but you are reading values from $_POST field.

    2) if you want to extract just the "description" meta value, you don't need to do the iteration over tags, you can just use:

    $description = $tags["description"]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了