線上書籍

Home

[991]PHP網站開發 進階應用技巧2

<?php
$url = "http://www.mobile01.com/";
$ch = curl_init();
$options[CURLOPT_URL]=$url;
$options[CURLOPT_HEADER]=false;
$options[CURLOPT_RETURNTRANSFER]=true;
$options[CURLOPT_USERAGENT]="Googlebot/2.1";
$options[CURLOPT_FOLLOWLOCATION]=true;

curl_setopt_array($ch, $options);
$output = curl_exec($ch);
curl_close($ch);
//echo "<base href='$url'>";
//echo $output;

preg_match_all("/newtopics\[.*\] = \'(.*)';/m", $output, $match);
$main="<table>\n";
foreach($match[1] as $link){
    $list=str_replace("topicdetail.php","{$url}topicdetail.php",$link);   
    $list=str_replace('" title="','" rel="lyteframe" rev="width: 1000px; height: 400px; scrolling: auto" title="',$list);
    preg_match("/title=\"(.*)\"/", $link, $title);
    $main.= "<tr><th>{$title[1]}</th><td>$list</td></tr>\n";
}
$main.="</table>";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel='stylesheet' href='style.css' type='text/css' />
  <title></title>
  <script type="text/javascript" language="javascript" src="lytebox.js"></script>
  <link rel="stylesheet" href="lytebox.css" type="text/css" media="screen" />
  </head>
  <body>
  <div id="news">
  <?php echo $main; ?>
  </div>
  </body>
</html>