修改hosts文件访问google服务

[html]
127.0.0.1 localhost
::1 localhost

##Chrome 网上应用店
203.208.46.90 chrome.google.com
203.208.46.90 clients0.google.com ##——————##
203.208.46.90 clients1.google.com ##可能和搜索建议有关##
203.208.46.90 clients2.google.com ##可能和搜索建议有关##
203.208.46.90 clients3.google.com ##可能和搜索建议有关##
203.208.46.90 clients4.google.com ##——————##

203.208.46.90 www.googleusercontent.com ##—————————–##
203.208.46.90 lh0.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh1.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh2.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh3.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh4.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh5.googleusercontent.com ##网页上的图片*好多服务都要用到##
203.208.46.90 lh6.googleusercontent.com ##—————————–##
203.208.46.90 clients1.googleusercontent.com
203.208.46.90 clients2.googleusercontent.com
203.208.46.90 browsersync.google.com ##看域名可能是同步

##网页快照
203.208.46.90 webcache.googleusercontent.com

##Google SSL
203.208.46.90 encrypted.google.com
203.208.46.90 encrypted.google.com.hk

##Google Docs
203.208.46.90 docs.google.com
203.208.46.90 docs0.google.com
203.208.46.90 docs1.google.com
203.208.46.90 docs2.google.com
203.208.46.90 docs3.google.com
203.208.46.90 spreadsheets.google.com
203.208.46.90 spreadsheets0.google.com
203.208.46.90 spreadsheets1.google.com
203.208.46.90 spreadsheets2.google.com
203.208.46.90 spreadsheets3.google.com

#Gmail
203.208.46.90 mail.google.com
203.208.46.90 chatenabled.mail.google.com #Gmail中Gtalk聊天服务

##Google 搜索
203.208.46.90 www.google.com

##Google preview
203.208.46.90 www.googlepreview.com

##Google 翻译
203.208.46.90 translate.google.com
203.208.46.90 translate.googleapis.com

##Google 搜索建议(IE9)
203.208.46.90 clients5.google.com

##Google code
203.208.46.90 code.google.com

##Picasa 网络相册
203.208.46.90 picasaweb.google.com
203.208.46.90 lh0.ggpht.com
203.208.46.90 lh1.ggpht.com
203.208.46.90 lh2.ggpht.com
203.208.46.90 lh3.ggpht.com
203.208.46.90 lh4.ggpht.com
203.208.46.90 lh5.ggpht.com
203.208.46.90 lh6.ggpht.com
203.208.46.90 lh7.ggpht.com
203.208.46.90 lh8.ggpht.com
203.208.46.90 lh8.ggpht.com
203.208.46.90 lh9.ggpht.com
203.208.46.90 lh6.google.com

##Google 个人资料
203.208.46.90 profiles.google.com

##Google+
203.208.46.90 talkgadget.google.com ##Google+中的聊天服务
203.208.46.90 ssl.gstatic.com ##Google+中的聊天服务
203.208.46.90 maps-api-ssl.google.com ##Google+中的地图定位服务
203.208.46.90 images-pos-opensocial.googleusercontent.com ##缩略图
203.208.46.90 images1-focus-opensocial.googleusercontent.com
203.208.46.90 images2-focus-opensocial.googleusercontent.com
203.208.46.90 images3-focus-opensocial.googleusercontent.com
203.208.46.90 images4-focus-opensocial.googleusercontent.com ##不知道有没有这几条
203.208.46.90 images5-focus-opensocial.googleusercontent.com #-_-*
203.208.46.90 images6-focus-opensocial.googleusercontent.com #-_-*

203.208.46.90 569005917268817437-a-wablog-info-s-sites.googlegroups.com ##今天突然发现的 不知道怎么会有这么一串没感的地址
203.208.46.90 safebrowsing-cache.google.com ##Google+里的游戏相关
203.208.46.90 images-oz-opensocial.googleusercontent.com
203.208.46.90 safebrowsing-cache.google.com
203.208.46.90 newsfeed-dot-latest-dot-rovio-ad-engine.appspot.com
203.208.46.90 plusone.google.com
203.208.46.90 r3085-dot-latest-dot-project-slingshot-gp.appspot.com
203.208.46.90 apis.google.com ##Google +1 button调用的JS主域名
203.208.46.90 plus.google.com

##Download 下载
203.208.46.90 dl.google.com
203.208.46.90 dl-ssl.google.com

##Groups
203.208.46.90 groups.google.com

##Google 博物馆
203.208.46.90 www.googleartproject.com

##Google URL Shortener
203.208.46.90 goo.gl

##Google app engine
203.208.46.90 appengine.google.com

##Google Maps
203.208.46.90 maps.google.com
203.208.46.90 maps.gstatic.com
203.208.46.90 cbk0.google.com ##街景
203.208.46.90 cbk1.google.com
203.208.46.90 cbk2.google.com
203.208.46.90 cbk3.google.com

##Google 纵横 ##与Google maps通用
203.208.46.90 mts.google.com
203.208.46.90 mts1.google.com
203.208.46.90 mts2.google.com
203.208.46.90 mts3.google.com
203.208.46.90 mts0.google.com
203.208.46.90 s2.googleusercontent.com
203.208.46.90 ssl.google-analytics.com
203.208.46.90 khms0.google.com ##混合地形
203.208.46.90 khms1.google.com
203.208.46.90 khms2.google.com
203.208.46.90 khms3.google.com

##Google 协作平台
203.208.46.90 sites.google.com
203.208.46.90 accounts.youtube.com ##登录协作平台时发现的 不知道有什么用

##Google Music beta
203.208.46.90music.google.com
203.208.46.90 t.doc-0-0-sj.sj.googleusercontent.com #个人音乐库
203.208.46.90 music-streaming.l.google.com
203.208.46.90 music.googleusercontent.com #音乐播放器 专辑封面 等
203.208.46.90 uploadsj.clients.google.com #客户端上传
203.208.46.90 large-uploads.l.google.com
203.208.46.90 themes.googleusercontent.com
203.208.46.90 csi.gstatic.com
203.208.46.90 video.google.com
[/html]

详细解释PHP中header和content-type 参数

void header ( string string [, bool replace [, int http_response_code]] )
void header ( string string [, bool replace [, int http_response_code]] )
header()是用来发送 HTTP Header的。replace是个可选的参数,指示是否替代一个先期相似的header,
或者增加第2个相同类型的header。默认的是替 代,但是如果你传递FALSE参数给第2个参数(即replace),你
能强制使用多个相同类型的header。例如:

第 二个可选的参数http_response_code强置HTTP响应代码的值。(PHP>4.3.0)
有两种特定的 header调 用。一种是header用字符串”HTTP/”开头的(大小写无所谓),它用
来指定发出的HTTP状态码。举个例子来说,如果你已经配置 Apache使用javascript:;” onClick=”javascript:tagshow(event, ‘PHP’);” target=”_self”>PHP脚 本来处理请求
不存在的文件(用ErrorDocument指令),你可能想确认你的脚本生成一个合适的状态码:

注意:HTTP状态行 总是最先发送给客户端的,不管你实际上在什么时候调用header()函数。
除非你的HTTP header已经发送出去了,否则,在任何时候,状态将会被header()函数用一个新的
状态行 覆盖。
在PHP 3中,只有PHP编译为Apache的模块是,并且用下面Staus Header才能取得同样的效果

第二中特殊的情况就是”Location:”header。如果没有某些 3xx的状态码已经发出的话,它不仅
发出Location行,而且发出一个重定向的状态码(302)。

注意:HTTP/1.1要求一个绝对 URI作为Location的参数:包括协议头,主机名和绝对路径,
但是某些客户端可以接受相对URI。你可 用$_SERVER[‘HTTP_HOST’] $_SERVER[‘PHP_SELF’]和
dirname()来从一个相对URI来产生绝对 URI。

PHP脚本通常生成一些动态的内容,不必被客户端的浏览器或者代理服务器缓 存。许多代理和客户端可以
强制禁止缓存:

注意:你可能发现即使你没有输出上面的header,你的页面还是不能被 缓存。可能是有几个选项改变了默认的
缓存行为。见sessrion_cache_limiter().
如果你想提示用户保 存你 发送过去的数据,比如一个已经生成的PDF文件,你可以用Content_Dispostion
头来提供一个推荐的文件名,强迫浏览器显示保存对 话框.

对 于IE,要加上Connection头
header(”HTTP/1.1 301 Moved Permanently”);
header(”Location: “.$url);
header(”Connection: close”);
header 中Content-type的种类 Content-type 的说明:
‘hqx’ -> ‘application/mac-binhex40’,
‘cpt’ -> ‘application/mac-compactpro’,
‘doc’ -> ‘application/msword’,
‘bin’ -> ‘application/octet-stream’,
‘dms’ -> ‘application/octet-stream’,
‘lha’ -> ‘application/octet-stream’,
‘lzh’ -> ‘application/octet-stream’,
‘exe’ -> ‘application/octet-stream’,
‘class’ -> ‘application/octet-stream’,
‘so’ -> ‘application/octet-stream’,
‘dll’ -> ‘application/octet-stream’,
‘oda’ -> ‘application/oda’,
‘pdf’ -> ‘application/pdf’,
‘ai’ -> ‘application/postscript’,
‘eps’ -> ‘application/postscript’,
‘ps’ -> ‘application/postscript’,
‘smi’ -> ‘application/smil’,
‘smil’ -> ‘application/smil’,
‘mif’ -> ‘application/vnd.mif’,
‘xls’ -> ‘application/vnd.ms-excel’,
‘ppt’ -> ‘application/vnd.ms-powerpoint’,
‘wbxml’ -> ‘application/vnd.wap.wbxml’,
‘wmlc’ -> ‘application/vnd.wap.wmlc’,
‘wmlsc’ -> ‘application/vnd.wap.wmlscriptc’,
‘bcpio’ -> ‘application/x-bcpio’,
‘vcd’ -> ‘application/x-cdlink’,
‘pgn’ -> ‘application/x-chess-pgn’,
‘cpio’ -> ‘application/x-cpio’,
‘csh’ -> ‘application/x-csh’,
‘dcr’ -> ‘application/x-director’,
‘dir’ -> ‘application/x-director’,
‘dxr’ -> ‘application/x-director’,
‘dvi’ -> ‘application/x-dvi’,
‘spl’ -> ‘application/x-futuresplash’,
‘gtar’ -> ‘application/x-gtar’,
‘hdf’ -> ‘application/x-hdf’,
‘js’ -> ‘application/x-javas
cript’,
‘skp’ -> ‘application/x-koan’,
‘skd’ -> ‘application/x-koan’,
‘skt’ -> ‘application/x-koan’,
‘skm’ -> ‘application/x-koan’,
‘latex’ -> ‘application/x-latex’,
‘nc’ -> ‘application/x-netcdf’,
‘cdf’ -> ‘application/x-netcdf’,
‘sh’ -> ‘application/x-sh’,
‘shar’ -> ‘application/x-shar’,
‘swf’ -> ‘application/x-shockwave-flash’,
‘sit’ -> ‘application/x-stuffit’,
‘sv4cpio’ -> ‘application/x-sv4cpio’,
‘sv4crc’ -> ‘application/x-sv4crc’,
‘tar’ -> ‘application/x-tar’,
‘tcl’ -> ‘application/x-tcl’,
‘tex’ -> ‘application/x-tex’,
‘texinfo’ -> ‘application/x-texinfo’,
‘texi’ -> ‘application/x-texinfo’,
‘t’ -> ‘application/x-troff’,
‘tr’ -> ‘application/x-troff’,
‘roff’ -> ‘application/x-troff’,
‘man’ -> ‘application/x-troff-man’,
‘me’ -> ‘application/x-troff-me’,
‘ms’ -> ‘application/x-troff-ms’,
‘ustar’ -> ‘application/x-ustar’,
‘src’ -> ‘application/x-wais-source’,
‘xhtml’ ‘application/xhtml+xml’,
‘xht’ -> ‘application/xhtml+xml’,
‘zip’ -> ‘application/zip’,
‘au’ -> ‘audio/basic’,
‘snd’ -> ‘audio/basic’,
‘mid’ -> ‘audio/midi’,
‘midi’ -> ‘audio/midi’,
‘kar’ -> ‘audio/midi’,
‘mpga’ -> ‘audio/mpeg’,
‘mp2’ -> ‘audio/mpeg’,
‘mp3’ -> ‘audio/mpeg’,
‘aif’ -> ‘audio/x-aiff’,
‘aiff’ -> ‘audio/x-aiff’,
‘aifc’ -> ‘audio/x-aiff’,
‘m3u’ -> ‘audio/x-mpegurl’,
‘ram’ -> ‘audio/x-pn-realaudio’,
‘rm’ -> ‘audio/x-pn-realaudio’,
‘rpm’ -> ‘audio/x-pn-realaudio-plugin’,
‘ra’ -> ‘audio/x-realaudio’,
‘wav’ -> ‘audio/x-wav’,
‘pdb’ -> ‘chemical/x-pdb’,
‘xyz’ -> ‘chemical/x-xyz’,
‘bmp’ -> ‘image/bmp’,
‘gif’ -> ‘image/gif’,
‘ief’ -> ‘image/ief’,
‘jpeg’ -> ‘image/jpeg’,
‘jpg’ -> ‘image/jpeg’,
‘jpe’ -> ‘image/jpeg’,
‘png’ -> ‘image/png’,
‘tiff’ -> ‘image/tiff’,
‘tif’ -> ‘image/tiff’,
‘djvu’ -> ‘image/vnd.djvu’,
‘djv’ -> ‘image/vnd.djvu’,
‘wbmp’ -> ‘image/vnd.wap.wbmp’,
‘ras’ -> ‘image/x-cmu-raster’,
‘pnm’ -> ‘image/x-portable-anymap’,
‘pbm’ -> ‘image/x-portable-bitmap’,
‘pgm’ -> ‘image/x-portable-graymap’,
‘ppm’ -> ‘image/x-portable-pixmap’,
‘rgb’ -> ‘image/x-rgb’,
‘xbm’ -> ‘image/x-xbitmap’,
‘xpm’ -> ‘image/x-xpixmap’,
‘xwd’ -> ‘image/x-xwindowdump’,
‘igs’ -> ‘model/iges’,
‘iges’ -> ‘model/iges’,
‘msh’ -> ‘model/mesh’,
‘mesh’ -> ‘model/mesh’,
‘silo’ -> ‘model/mesh’,
‘wrl’ -> ‘model/vrml’,
‘vrml’ -> ‘model/vrml’,
‘css’ -> ‘text/css’,
‘html’ -> ‘text/html’,
‘htm’ -> ‘text/html’,
‘asc’ -> ‘text/plain’,
‘txt’ -> ‘text/plain’,
‘rtx’ -> ‘text/richtext’,
‘rtf’ -> ‘text/rtf’,
‘sgml’ -> ‘text/sgml’,
‘sgm’ -> ‘text/sgml’,
‘tsv’ -> ‘text/tab-separated-values’,
‘wml’ -> ‘text/vnd.wap.wml’,
‘wmls’ -> ‘text/vnd.wap.wmlscript’,
‘etx’ -> ‘text/x-setext’,
‘xsl’ -> ‘text/xml’,
‘xml’ -> ‘text/xml’,
‘mpeg’ -> ‘video/mpeg’,
‘mpg’ -> ‘video/mpeg’,
‘mpe’ -> ‘video/mpeg’,
‘qt’ -> ‘video/quicktime’,
‘mov’ -> ‘video/quicktime’,
‘mxu’ -> ‘video/vnd.mpegurl’,
‘avi’ -> ‘video/x-msvideo’,
‘movie’ -> ‘video/x-sgi-movie’,
‘ice’ -> ‘x-conference/x-cooltalk’

让PHP更快的提供文件下载

一般来说, 我们可以通过直接让URL指向一个位于Document Root下面的文件, 来引导用户下载文件.

但是, 这样做, 就没办法做一些统计, 权限检查, 等等的工作. 于是, 很多时候, 我们采用让PHP来做转发, 为用户提供文件下载.
[php]
<?php
<?php
$file = ‘monkey.gif’;

if (file_exists($file)) {
header(‘Content-Description: File Transfer’);
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename=’.basename($file));
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
[/php]
但是这个有一个问题, 就是如果文件是中文名的话, 有的用户可能下载后的文件名是乱码.

于是, 我们做一下修改(参考: :
[php]
<?php
$file = "/tmp/中文名.tar.gz";

$filename = basename($file);

header("Content-type: application/octet-stream");

//处理中文文件名
$ua = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
if (preg_match("/MSIE/", $ua)) {
header(‘Content-Disposition: attachment; filename="’ . $encoded_filename . ‘"’);
} else if (preg_match("/Firefox/", $ua)) {
header("Content-Disposition: attachment; filename*="utf8”" . $filename . ‘"’);
} else {
header(‘Content-Disposition: attachment; filename="’ . $filename . ‘"’);
}

header(‘Content-Disposition: attachment; filename="’ . $filename . ‘"’);
header("Content-Length: ". filesize($file));
readfile($file);
[/php]
恩, 现在看起来好多了, 不过还有一个问题, 那就是readfile, 虽然PHP的readfile尝试实现的尽量高效, 不占用PHP本身的内存, 但是实际上它还是需要采用MMAP(如果支持), 或者是一个固定的buffer去循环读取文件, 直接输出.

输出的时候, 如果是Apache + PHP mod, 那么还需要发送到Apache的输出缓冲区. 最后才发送给用户. 而对于Nginx + fpm如果他们分开部署的话, 那还会带来额外的网络IO.

那么, 能不能不经过PHP这层, 直接让Webserver直接把文件发送给用户呢?

今天, 我看到了一个有意思的文章: How I PHP: X-SendFile.

我们可以使用Apache的module mod_xsendfile, 让Apache直接发送这个文件给用户:
[php]
<?php
$file = "/tmp/中文名.tar.gz";

$filename = basename($file);

header("Content-type: application/octet-stream");

//处理中文文件名
$ua = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = urlencode($filename);
$encoded_filename = str_replace("+", "%20", $encoded_filename);
if (preg_match("/MSIE/", $ua)) {
header(‘Content-Disposition: attachment; filename="’ . $encoded_filename . ‘"’);
} else if (preg_match("/Firefox/", $ua)) {
header("Content-Disposition: attachment; filename*="utf8”" . $filename . ‘"’);
} else {
header(‘Content-Disposition: attachment; filename="’ . $filename . ‘"’);
}

header(‘Content-Disposition: attachment; filename="’ . basename($file) . ‘"’);

//让Xsendfile发送文件
header("X-Sendfile: $file");
[/php]
X-Sendfile头将被Apache处理, 并且把响应的文件直接发送给Client.
Lighttpd和Nginx也有类似的模块, 大家有兴趣的可以去找找看

抓取全国两千多个城市的天气预报

采用新浪SAE的Fetchurl 、KVDB、cron服务,抓取天气预报,速度快,准确。
中央气象台提供一个API可以查询最近六天的天气,返回的格式为json,例如http://m.weather.com.cn/data/101200101.html 101200101为该城市武汉的城市代码,所以只要我们知道城市代码,就可以抓取该城市天气了。笔者准备了经过了筛选的全国所有城市的数据,这些数据经过本人通过编程手段一一检验,保证真实有效,mysql数据库文件下载链接http://www.kuaipan.cn/file/id_33799150646592444.html ,excel文件下载链接http://www.kuaipan.cn/file/id_33799150646592446.html
好的,我先说下大题思路:
1.抓取几个城市的天气比较容易,简单的编程就可以实现了,但是抓取两千多个城市的天气并不容易:
(1)网络延迟可能发生,不容易保证准确率,做到不重复不漏数据
(2)PHP脚本运行时间有限制,如果一次运行的话,脚本至少要运行近两个小时,而PHP默认限制是30S
2.初开始我想在每天凌晨自动把城市数据装进数据库,然后在早上九点开始抓取,每一分钟运行一次脚本,每个脚本抓取20条数据,然后每抓取成功一次数据,从数据库删除这个城市记录,后来测试一下,数据库读写太频繁,豆豆消耗太多,效率不太高。
3.经过分析,决定采用KVDB,读写速度极快,装入两千六百条数据只用了5秒左右。
代码如下:
装入城市ID的代码,命名为KV.php:

[php]
<?php
$mysql = new SaeMysql();
$sql = "SELECT * FROM `city` ";
$data = $mysql->getData( $sql ); //从数据库取出所有城市信息
$num=count($data);
$kv = new SaeKV();
$ret = $kv->init(); //初始化KVDB服务
for($i=0;$i<$num;$i++)
{
$cityid=$data[$i][‘cityid’];
$cityname=$data[$i][‘cityname’];
$ret = $kv->set($cityid, $cityname);

}
?>
[/php]

抓取数据代码,命名为curl.php

[php]
$kv = new SaeKV();
$mysql = new SaeMysql();
$mysql->setCharset(‘UTF8’);
$ret = $kv->init();
$result=$kv->pkrget(”,20);//从KVDB取出20条数据
$f = new SaeFetchurl();
foreach($result as $key=>$value)
{
$url="http://m.weather.com.cn/data/".$key.".html";
if($content = $f->fetch($url))
{

$data=json_decode($content,true);
$data=$data[‘weatherinfo’];
$cityid=$key;
$tl=array();
$th=array();
$wind=array();
$fl=array();
$fx=array();
$weather=array();
for($i=1;$i<7;$i++)
{
$tmp=0;
$temparray=explode("℃",$data[‘temp’.$i]);
$th[$i]=$temparray[0];
$tltemp=explode("~",$temparray[1]);
$tl[$i]=$tltemp[1];
if($tl[$i]>$th[$i])
{
$tmp=$th[$i];
$th[$i]=$tl[$i];
$tl[$i]=$tmp;
}
if(isset($data[‘wind’.$i]))
{
$wind[$i]=$data[‘wind’.$i];}
else{
$wind[$i]="无数据";
}
if(isset($data[‘fl’.$i]))
{
$fl[$i]=$data[‘fl’.$i];}
else{
$fl[$i]="无数据";

}
if(isset($data[‘fx’.$i]))
{
$fx[$i]=$data[‘fx’.$i];}
else{

$fx[$i]="无数据";

}
if(isset($data[‘weather’.$i])){
$weather[$i]=$data[‘weather’.$i];}
else{
$weather[$i]="无数据";

}

}
$cityname=$data[‘city’];
$time=time();
$time=date("Y-m-d" ,$time);
$sql="insert into weather(cityid,cityname,time,tl1,tl2,tl3,tl4,tl5,tl6,th1,th2,th3,th4,th5,th6,wind1,wind2,wind3,wind4,wind5,wind6,fl1,fl2,fl3,fl4,fl5,fl6,fx1,fx2,fx3,fx4,fx5,fx6,weather1,weather2,weather3,weather4,weather5,weather6) values( ‘" . $mysql->escape( $cityid ) . "’ ,’" . $mysql->escape( $cityname ) . "’ ,’" . $mysql->escape( $time) . "’ ,
‘" . $mysql->escape( $tl[1] ) . "’ ,’" . $mysql->escape( $tl[2]) . "’ ,’" . $mysql->escape( $tl[3]) . "’ ,’" . $mysql->escape( $tl[4] ) . "’ ,’" . $mysql->escape( $tl[5] ) . "’ ,’" . $mysql->escape( $tl[6]) . "’ ,
‘" . $mysql->escape( $th[1] ) . "’ ,’" . $mysql->escape( $th[2] ) . "’ ,’" . $mysql->escape( $th[3] ) . "’ ,’" . $mysql->escape( $th[4] ) . "’ ,’" . $mysql->escape( $th[5] ) . "’ ,’" . $mysql->escape( $th[6] ) . "’ ,
‘" . $mysql->escape( $wind[1] ) . "’ ,’" . $mysql->escape( $wind[2] ) . "’ ,’" . $mysql->escape( $wind[3] ) . "’ ,’" . $mysql->escape( $wind[4] ) . "’ ,’" . $mysql->escape( $wind[5] ) . "’ ,’" . $mysql->escape( $wind[6] ) . "’ ,
‘" . $mysql->escape( $fl[1] ) . "’ ,’" . $mysql->escape( $fl[2] ) . "’ ,’" . $mysql->escape( $fl[3] ) . "’ ,’" . $mysql->escape( $fl[4] ) . "’ ,’" . $mysql->escape( $fl[5] ) . "’ ,’" . $mysql->escape( $fl[6] ) . "’ ,
‘" . $mysql->escape( $fx[1] ) . "’ ,’" . $mysql->escape( $fx[2] ) . "’ ,’" . $mysql->escape( $fx[3] ) . "’ ,’" . $mysql->escape( $fx[4] ) . "’ ,’" . $mysql->escape( $fx[5] ) . "’ ,’" . $mysql->escape( $fx[6] ) . "’ ,
‘" . $mysql->escape( $weather[1] ) . "’ ,’" . $mysql->escape( $weather[2] ) . "’ ,’" . $mysql->escape( $weather[3] ) . "’ ,’" . $mysql->escape( $weather[4] ) . "’ ,’" . $mysql->escape( $weather[5] ) . "’ ,’" . $mysql->escape( $weather[6] ) . "’
)";
$mysql->runSql($sql);
if( $mysql->errno() != 0 )
{
die( "Error:" . $mysql->errmsg() );
}else{
$kv->delete($key);//读取成功从KVDB删除这条记录,否则保留,下次继续抓取

}
}
}
[/php]

然后编写定时执行命令就行

[shell]
cron:
– description: weather
url: curl.php
schedule: every 1 min
– description: kv
url: kv.php
schedule: every day of month 10:00
[/shell]