如何用js调用天气预报代码 最新

JavaScript025

如何用js调用天气预报代码 最新,第1张

直接使用插件,如

<iframe width="214" scrolling="no" height="54" frameborder="0" allowtransparency="true" src="http://i.tianqi.com/index.php?c=code&id=42&icon=1&num=3"></iframe>

效果如下

这个插件来源是http://www.tianqi.com/plugin/

<center><p><b>天 气 预 报</b></cenier>

<center><iframe width=157 height=240 frameborder=0 scrolling=NO src='http://appnews.qq.com/cgi-bin/news_qq_search?city=城市名称></iframe></center>

说明:城市名称写下面的代码

中国其他各省(区)天气的代码只需将上述代码中的 cncn 换成下列字符串:

广东: gudp 福建: fujp 浙江: zhjp 江苏:jsup 安徽: anhp 山东: shdp

海南: hanp 广西: guxa 贵州: guzp 云南:yunp 四川: sicp 陕西: saxp

河南: henp 河北: hebp 山西: shxp 内蒙古:nema 辽宁: linp 吉林: jilp

黑龙江: hljp 湖北: hubp 湖南: hunp 江西:jixp 甘肃: gasp 宁夏: nixa

青海: qihp 西藏: xiza 新疆: xija

其它国家天气的代码只需将上述代码中的 cncn 换成下列字符串: :

德国:dldl 美国:naus 加拿大:naka 亚洲:asie 欧洲:euro

日本:japn 韩国:skor 朝鲜:nkor

//给你一个网址

//http://m.weather.com.cn/data/101010100.html

//http://blog.csdn.net/hello_haozi/article/details/7564223

NSString *shangHai = @"http://m.weather.com.cn/data/101020100.html"

NSOperationQueue *queue = [[NSOperationQueue alloc] init]

NSURL *url1 = [NSURL URLWithString:shangHai]

NSURLRequest *request1 = [[NSURLRequest alloc] initWithURL:url1]

[NSURLConnection sendAsynchronousRequest:request1 queue:queue completionHandler:^(NSURLResponse *response, NSData *da, NSError *error) {

if (da) {

NSDictionary *shangHaiDict = [NSJSONSerialization JSONObjectWithData:da options:NSJSONReadingMutableLeaves error:&error]

NSLog(@"%@",shangHaiDict)

}

}]

这是上海的天气 ,不知道是否回答了你的问题