PHP 获取acm近期比赛

复制代码
<?php
// author: Moore Jiang.
ini_set('display_errors',1);            //错误信息  
    ini_set('display_startup_errors',1);    //php启动错误信息  
    error_reporting(-1);                    //打印出所有的 错误信息  
    ini_set('error_log', dirname(__FILE__) . '/error2_log.txt'); 
$url = 'http://contests.acmicpc.info/contests.json';
//初始化
$ch = curl_init();
//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
//执行并获取HTML文档内容
$output = curl_exec($ch);
//释放curl句柄
curl_close($ch);
//打印获得的数据
// print_r($output);
$obj = json_decode($output);
// for ($i=0; $i < count($obj) ; $i++) {
//     echo $obj[$i]->id;
//     echo $obj[$i]->oj;
// }
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="icon" href="http://www.yinghualuowu.com/img/ico/bitbug_favicon.ico"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
  </head>

<body>
    <div class="container">
        <div class="jumbotron">
            <div id=main>
                <table width=80% align=center>
                    <thead class=toprow>
                        <tr>
                            <th class="column-1">OJ</th>
                            <th class="column-2">Name</th>
                            <th class="column-3">Start Time</th>
                            <th class="column-4">Week</th>
                            <th class="column-5">Access</th>
                        </tr>
                    </thead>
                    <tbody class="row-hover">
                        <?php
                        for ($i=0; $i < count($obj); $i++) {
                            ?>
                            <tr>
                                  <td> <?php echo $obj[$i]->oj; ?> </td>
                                <td class="column-2"><a id="<?php echo $obj[$i]->id; ?>" href=" <?php echo $obj[$i]->link; ?> " target="_blank"> <?php echo $obj[$i]->name; ?> </a></td>
                                <td class="column-3"> <?php echo $obj[$i]->start_time; ?> </td>
                                <td class="column-4"> <?php echo $obj[$i]->week; ?> </td>
                                <td class="column-5"> <?php echo $obj[$i]->access; ?> </td>
                              </tr>
                        <?php
                        }
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>
<!--not cached-->
复制代码

http://www.yinghualuowu.com/php/recent_contest.php

posted @   樱花落舞  阅读(378)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
历史上的今天:
2016-09-22 Codeforces Round #372 (Div. 2) C
点击右上角即可分享
微信分享提示