首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 網頁程式設計 >> PHP 程式設計 >> PHP 綜合知識

2012 倫敦奧運獎牌榜 PHP 代碼

     編輯:PHP 綜合知識

即時抓取獎牌榜資料

<?php
define('SINA_SAE', '0'); // 是否啟用新浪 SAE 平台
$ayurl = "https://2012.titan24.com/medal.html";
$content = fcontents($ayurl);
preg_match_all('<div class="box bdr1">(.*)</table>isU', $content, $table);
echo '<html lang="zh-CN" xml:lang="zh-CN" xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>奧運獎牌榜-2012倫敦奧運會-同窮論壇</title>
<meta name="description" content="同窮論壇提供最新,最準確,最專業,最權威的2012倫敦奧運會獎牌榜。" />
<meta name="keywords" content="2012倫敦奧運會,獎牌榜,金牌榜,中美爭霸,同窮論壇" />
<style>
.time {height: 24px;padding: 10px;}
.fR {float: right;}.fL {float: left;}
table.ctab {font-family: Arial,Helvetica,sans-serif;width: 750px;}
table {border-collapse: collapse;border-spacing: 0;}
table.ctab th {background: #F1F3F4;color: #0C48A0;font-size: 14px;font-weight: bold;height: 28px;text-align: center;}
table.ctab td {color: #000000;font-size: 14px;height: 28px;line-height: 28px;text-align: center;}
table.ctab td.na, table.ctab th.na {padding-left: 16px;text-align: left;}
table.ctab td.red {color: #DD0000;}
table.ctab td.blue {color: #00509C;}
</style>'.$table[1][0].'</table>
<div align="center"><a href="https://www.php100.com">php100論壇</a></div>';

function fcontents($a) { // 取得內容
    if (SINA_SAE) {
        $f = new SaeFetchurl();
        $content = $f->fetch($a);
        if ($f->errno() == 0) $r = $content;
        else $r = $f->errmsg();
    } else {
        $r = @file_get_contents($a);
    }
    return $r;
}
?>
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved