本文整理汇总了Python中six.moves.urllib.request.Request.get方法的典型用法代码示例。如果您正苦于以下问题:Python Request.get方法的具体用法?Python Request.get怎么用?Python Request.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.urllib.request.Request
的用法示例。
在下文中一共展示了Request.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recurse_directory_dict
# 需要导入模块: from six.moves.urllib.request import Request [as 别名]
# 或者: from six.moves.urllib.request.Request import get [as 别名]
def recurse_directory_dict( url_opener, cur_options, url ):
cur_directory = Request( url, headers={ 'Content-Type': 'application/json', 'Accept': 'application/json, text/plain' } )
cur_directory.get_method = lambda: 'GET'
# get url to upload to
try:
cur_directory = url_opener.open( cur_directory ).read()
except HTTPError as e:
log.debug( 'GenomeSpace export tool failed reading a directory "%s": %s' % ( url, e ) )
return # bad url, go to next
cur_directory = json.loads( cur_directory )
directory = cur_directory.get( 'directory', {} )
contents = cur_directory.get( 'contents', [] )
if directory.get( 'isDirectory', False ):
selected = directory.get( 'path' ) == value
cur_options.append( { 'name': directory.get( 'name' ), 'value': directory.get( 'path'), 'options': [], 'selected': selected } )
for sub_dir in contents:
if sub_dir.get( 'isDirectory', False ):
recurse_directory_dict( url_opener, cur_options[-1]['options'], sub_dir.get( 'url' ) )