PHP實現(xiàn)新型冠狀病毒疫情實時圖的實例
更新時間:2020年02月04日 08:55:10 作者:myhaochi
在本篇文章小編給大家分享一篇關(guān)于PHP新型冠狀病毒肺炎疫情實時圖源碼內(nèi)容,有興趣的朋友們可以本地測試下。
我們先來看一下運行圖
下面我們來看源代碼:
<?php //抓取抖音的接口數(shù)據(jù) global $nCov_data; $nCov_data['data']=get_nCoV_douyin_news(); $nCov_data['total']=get_nCoV_douyin_total(); function get_nCoV_douyin_news(){ $content=@file_get_contents('https://i.snssdk.com/api/feed/forum_flow/v1/?forum_id=1656388947394568&is_web_refresh=1&channel=local_test&query_id=1656388947394568&tab_id=1656388947394584&is_preview=1&stream_api_version=82&aid=13&forum_id=1656388947394568&is_preview=0'); $c=count(json_decode($content)->data)-1; $getInfos=@json_decode(json_decode($content)->data[$c]->content)->sub_raw_datas; if ($getInfos){ foreach ($getInfos as $k=>$Info){ $data[$k]=[ 'showtime'=>$Info->raw_data->showtime_string,//展示時間 'desc'=>$Info->raw_data->desc,//簡訊 'event_time'=>$Info->raw_data->event_time//真實播報時間 ]; } return $data; }else{ return false; } } function get_nCoV_douyin_total(){ $content=@file_get_contents('https://i.snssdk.com/forum/home/v1/info/?forum_id=1656388947394568&is_web_refresh=1'); $getInfos=@json_decode(json_decode($content)->forum->extra->ncov_string_list); $data['desc']=@json_decode($content)->forum->rich_content; $data['img']=@json_decode($content)->forum->extra->ncov_image_url; if ($getInfos){ foreach ($getInfos as $k=>$Info){ $data['provinces'][$k]=$Info; } return $data; }else{ return false; } } ?> <!doctype html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta author="__Mark_Cheng__QQ72817"> <link rel="stylesheet" href="CSS/index.css" rel="external nofollow" > <title>實時更新:新型冠狀病毒肺炎疫情</title> </head> <body> <div class="view"> <div class="header"> <div class="title">新型冠狀病毒肺炎</div> <div class="to-title">疫情通報</div> </div> <div class="show"> <div class="total"> <p class="title"><span>實時疫情狀況</span><span>數(shù)據(jù)抓取時間:<?php echo date('Y.m.d H:i');?></span></p> <p class="desc"><?php echo $nCov_data['total']['desc'];?></p> </div> <div class="map"> <img src="<?php echo $nCov_data['total']['img'];?>" alt="實時地圖" width="100%"> </div> <div class="list"> <ul> <?php foreach ($nCov_data['total']['provinces'] as $key=>$val){ echo '<li><span>'.$val.'</span></li>'; } ?> </ul> </div> <div class="timeline"> <div class="title">疫情追蹤</div> <div class="c"> <?php foreach ($nCov_data['data'] as $key=>$val){ ?> <div class="content"> <div class="i"></div> <div class="c"> <div class="show_time"> <?php echo date('m月d日 H:i',$val['event_time']);?> </div> <div class="desc"> <?php echo $val['desc'];?> </div> </div> </div> <?php } ?> </div> </div> <div class="tip"> <img src="https://mat1.gtimg.com/news/images/inews/2020/feiyan/18/img/prevent.png" alt="溫馨提示" width="100%"> </div> </div> </div> </body> </html>
分析:其中PHP代碼中的圖片路徑可以自己保存到本地進行修改。
感謝大家的學習和對腳本之家的支持。
您可能感興趣的文章:
- python+selenium定時爬取丁香園的新型冠狀病毒數(shù)據(jù)并制作出類似的地圖(部署到云服務(wù)器)
- node爬取新型冠狀病毒的疫情實時動態(tài)
- 將新型冠狀病毒轉(zhuǎn)二進制的代碼(首發(fā))
- Python抓新型冠狀病毒肺炎疫情數(shù)據(jù)并繪制全國疫情分布的代碼實例
- Python實現(xiàn)新型冠狀病毒傳播模型及預測代碼實例
- Python實現(xiàn)實時數(shù)據(jù)采集新型冠狀病毒數(shù)據(jù)實例
- python模擬預測一下新型冠狀病毒肺炎的數(shù)據(jù)
- 使用Python制作新型冠狀病毒實時疫情圖
- pyecharts繪制中國2020肺炎疫情地圖的實例代碼
相關(guān)文章
windows中為php安裝mongodb與memcache
這篇文章主要介紹了windows中為php安裝mongodb與memcache的方法,十分的詳盡,需要的朋友可以參考下2015-01-01ThinkPHP中I(),U(),$this->post()等函數(shù)用法
這篇文章主要介紹了ThinkPHP中I(),U(),$this->post()等函數(shù)用法,簡單分析了ThinkPHP處理表單的常用函數(shù)使用方法,具有一定的參考借鑒價值,需要的朋友可以參考下2014-11-11Zend Framework生成驗證碼并實現(xiàn)驗證碼驗證功能(附demo源碼下載)
這篇文章主要介紹了Zend Framework生成驗證碼并實現(xiàn)驗證碼驗證功能,較為詳細的分析講述了Zend Framework實現(xiàn)操作驗證碼操作的具體步驟與相關(guān)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-03-03php curl模擬post請求和提交多維數(shù)組的示例代碼
這篇文章主要介紹了php curl模擬post請求和提交多維數(shù)組的示例代碼,需要的朋友可以參考下2015-11-11PHP查詢數(shù)據(jù)庫中滿足條件的記錄條數(shù)(兩種實現(xiàn)方法)
在需要輸出網(wǎng)站用戶注冊數(shù)或者插入數(shù)據(jù)之前判斷是否有重復記錄時,就需要獲取滿足條件的MySQL查詢的記錄數(shù)目,接下來介紹兩種查詢統(tǒng)計方法,感興趣的朋友可以了解下啊,或許對你有所幫助2013-01-01php中配置文件保存修改操作 如config.php文件的讀取修改等操作
有時候我們需要用php將一些配置參數(shù)寫到文件里面,方便后期讀取使用,這里就為大家分享一下具體的實現(xiàn)代碼,需要的朋友可以參考一下2021-05-05