#!/usr/bin/env python # -*- encoding: utf-8 -*- # NOTE/2008 SOLREX: This script is not maintained to adapt new changes. # weatherman.sh is what you need @ http://share.solrex.org/scripts/weatherman.sh. import os import urllib city_list = { '南京': '101190101', '北京': '101010100', '郑州': '101180101', } my_cities = ['南京','北京'] weather_users = { 'yyyyyyyy': '郑州', } class weather: urlbase = "http://www.weather.com.cn/html/weather/" def __init__(self): pass def clear_html(self): for city in city_list.keys(): cmd = "rm -f %s.htm" % (city) os.popen(cmd) def get_html(self): for city in city_list.keys(): url = self.urlbase + city_list[city] + '.shtml' cmd = "wget -O %s.htm %s" % (city, url) os.popen(cmd) return 0 def parse_html(self): for city in city_list: filename = city + ".htm" # Select specific part. cmd = "sed -i -e '/surf/,1000d;1,/dd_0/d;' %s" % (filename) os.popen(cmd) # Remove html tag cmd = "sed -i -e 's/<[^>]*>//g;/