def get_ip():
    try:
        url = "http://cn.bing.com/search?q=ip&go=%E6%8F%90%E4%BA%A4&qs=n&form=QBLH&pq=ip&sc=8-2&sp=-1&sk=&cvid=14b93b305cdc4183875411c3d9edf938"  
        html = urllib2.urlopen(url).read()  
        
        print re.findall('本机 ip: (.+?)</div>',html)[0]
            
    except Exception, e:
        print traceback.format_exc()

  

相关文章: