我為了讓程式更有效率一點,所以用這個來判斷網頁型態,來得知是否得到網頁內容,並去做分析動作。詳細程式碼請入內觀看吧! 謝謝~~

<form id="form" name="form" method="post" action="index.php">
      URL: <input type="text" name="url" />

      <label>
            <input type="submit" value="Enter" />
      </label>
</form>

<?php
$url = $_POST['url'];

if($url != '')
{
      $contentType = @get_headers($url, 1);
     
      if(eregi("^text/html", $contentType['Content-Type'])) //html
      {
            echo "Content-Type: text/html";
      }
      else if(eregi("^text/plain", $contentType['Content-Type'])) //txt
      {
            echo "Content-Type: text/plain";
      }
      else
      {
            echo "Content-Type: ";
      }
}
?>

以上程式範例若有錯誤,也請告知或糾正,謝謝~~
給我建議也可以,因為我應該寫的不好

arrow
arrow
    全站熱搜

    dreamtails 發表在 痞客邦 留言(0) 人氣()