参加广播节目 [英] Take Broadcast program
本文介绍了参加广播节目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个频道发布站点,我想进入频道CNN广播节目.
I have a channel publishing sites and I wanna get into the channel CNN broadcast program..
CNN在这里播放了该节目:(您可以在源代码中看到)
CNN broadcast the program here: (you can see in source)
http://edition.cnn.com//CNNI/schedules/json/CSI.EU.html
如何根据提款时间提取数据?
How the data according to the time of withdrawal?
例如
Now program: "overflow's table"
next program: "stack's table" in 30 minute
这可能吗?
推荐答案
是的,有可能:
<?php
$html = file_get_contents('http://edition.cnn.com//CNNI/schedules/json/CSI.EU.html');
preg_match('#<textarea id="jsCode">(.*)</textarea>#is', $html, $matches);
$json = trim($matches[1]);
$json = str_replace("'", '"', $json);
$json = preg_replace('#([\w]+): ("|\[)#is', '"\\1": \\2', $json);
$json = json_decode($json, TRUE);
$startTimeUnix = time();
foreach($json['airings'] as $key => $value)
{
if ($value['startTimeUnix'] > $startTimeUnix)
break;
}
echo 'Now: ' , $json['airings'][$key]['programName']; # CNN Newsroom
echo 'Next: ', $json['airings'][++$key]['programName']; # World Sport
这篇关于参加广播节目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文