Chinaunix

标题: 城市天气查询(Python) [打印本页]

作者: bbflyerwww    时间: 2006-09-04 23:00
标题: 城市天气查询(Python)

# coding: cp936
"""
    查询城市天气情况
    信息来源网 weather.news.sohu.com
    Author : 寒江风
    QQ : 84640008
    Date : 2006-09-05
"""
import urllib
import re
def main():
    # Show Information
    print '中国城市天气查询'
    # Get Parameters
    city = raw_input('请输入您要查询天气的城市名字(如汕头,广州...) : ')
    # Request For The Web Page
    params = urllib.urlencode({'city':city})
    webpage = urllib.urlopen('http://weather.news.sohu.com/city_inc.php?%s' % params)
    webdata = webpage.read().replace('\n', '')
    # Match The Useful Information
    pattern = re.compile('([^


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22660/showart_164945.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2