import re urlinfo = '''http://www.cnpythoner.com/post/181.html url2 url3 ''' def ping(webname,hosturl,linkurl): import xmlrpclib rpc_server = xmlrpclib.ServerProxy('http://blogsearch.google.com/ping/RPC2 ') result = rpc_server.weblogUpdates.extendedPing(webname,hosturl,linkurl) print result if result.get('flerror', False) == True: print 'ping error' else: print 'ping success' def get_url(url): '''获取标准的url''' host_re = re.compile(r'^https?://(.*?)($|/)', re.IGNORECASE ) return host_re.search(url).group(0) info = urlinfo.split('\n') for m in info: webname = m.split('.')[1] hosturl = get_url(m) ping(webname,hosturl,m) #//python/5709