【转】判断URL是否能够访问

import urllib2

def file_exists(url):
    request = urllib2.Request(url)
    request.get_method = lambda : 'HEAD'
    try:
        response = urllib2.urlopen(request)
        return True
    except:
        return False

 原文地址:http://mysrc.sinaapp.com/view_note/?id=395

 
posted @ 2016-03-31 09:04  Jarning_Gau  阅读(311)  评论(0编辑  收藏  举报