本文整理匯總了Python中InternetArchiveCommon.get_docketxml_url方法的典型用法代碼示例。如果您正苦於以下問題:Python InternetArchiveCommon.get_docketxml_url方法的具體用法?Python InternetArchiveCommon.get_docketxml_url怎麽用?Python InternetArchiveCommon.get_docketxml_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類InternetArchiveCommon
的用法示例。
在下文中一共展示了InternetArchiveCommon.get_docketxml_url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: archive_docket_xml_locally
# 需要導入模塊: import InternetArchiveCommon [as 別名]
# 或者: from InternetArchiveCommon import get_docketxml_url [as 別名]
def archive_docket_xml_locally(court, casenum, directory = "archived_dockets"):
docket_url = IACommon.get_docketxml_url(court, casenum)
if os.system("wget --quiet --directory-prefix=%s %s" % (directory, docket_url)) != 0:
print "Could not archive this docket, exiting without trying to delete..."
exit()
print " saved docket %s.%s for analysis in %s directory" % (court, casenum, directory)
示例2: get_docket_string
# 需要導入模塊: import InternetArchiveCommon [as 別名]
# 或者: from InternetArchiveCommon import get_docketxml_url [as 別名]
def get_docket_string(court, casenum):
docketurl = IACommon.get_docketxml_url(court, casenum)
request = urllib2.Request(docketurl)
try:
response = opener.open(request)
except urllib2.HTTPError, e: # HTTP Error
if e.code == 404:
bits = e.read()
# IA returns different 404 pages if the bucket exists or not
# This might be a brittle way to check the difference, but don't think there's a better way
if(bits.find(NO_BUCKET_HTML_MESSAGE) > 0):
return None, FETCH_NO_BUCKET
# Otherwise, assume the bucket exists
return None, FETCH_NO_FILE
else:
logging.info("get_docket_string: unknown fetch code %d" % e.code)
return None, FETCH_UNKNOWN