Yahoo天气小偷
也就是右边那个天气预报
Crontab:
*/30 * * * * /usr/home/ken/sh/sed_yahoo_bj.sh
—————————–
db# more sed_yahoo_bj.sh
#!/bin/sh
/usr/local/bin/wget -O /tmp/bj.xml -i /usr/home/ken/sh/list_beijing
sleep 1
cp /tmp/bj.xml /tmp/bj.xml.bak
sed ’37s/^.*$//;w /tmp/bj.xml’ /tmp/bj.xml.bak
cp /tmp/cq.xml /tmp/cq.xml.bak
sed ’38s/^.*$//;w /tmp/bj.xml’ /tmp/bj.xml.bak
cp /tmp/cq.xml /tmp/cq.xml.bak
sed ’36s/^.*$//;w /tmp/bj.xml’ /tmp/bj.xml.bak
db# more list_beijing
http://xml.weather.yahoo.com/forecastrs … p=CHXX0008
—————————-
其中XML库为公用的php-Rss库文件
<?php
require_once “XML/RSS.php”;
$rss =& new XML_RSS(“/tmp/bj.xml”);
$rss->parse();
foreach ($rss->getItems() as $item) {
echo “” . $item[‘title’] . “<br/>\n ” . $item[‘description’] . ” “;
}
//weather update time
$filemod = filemtime(“/tmp/bj.xml”);
$filemodtime = date(“F/j/Y h:i:s A”, $filemod);
print(“更新时间: $filemodtime<br/>”);
?>