Python 2.7 如何在aws定价boto3 api get产品中使用页面迭代器
如何对迭代aws定价api以获取价格的结果进行分页 以下是我尝试的内容,但没有属性“getitem”出现错误Python 2.7 如何在aws定价boto3 api get产品中使用页面迭代器,python-2.7,amazon-web-services,pagination,boto3,Python 2.7,Amazon Web Services,Pagination,Boto3,如何对迭代aws定价api以获取价格的结果进行分页 以下是我尝试的内容,但没有属性“getitem”出现错误 pricing = boto3.client('pricing', region_name='us-east-1') token = '' paginator = pricing.get_paginator('get_products') while True: response = paginator.paginate( ServiceCode='AmazonE
pricing = boto3.client('pricing', region_name='us-east-1')
token = ''
paginator = pricing.get_paginator('get_products')
while True:
response = paginator.paginate(
ServiceCode='AmazonEC2',
Filters=[
{'Type': 'TERM_MATCH', 'Field': 'operatingSystem', 'Value': 'Linux'},
{'Type': 'TERM_MATCH', 'Field': 'location', 'Value': 'US West (Oregon)'}
],
PaginationConfig={
'MaxItems':100,
'PageSize':100,
'StartingToken':token
}
)
token = response['NextToken']
print response.result_keys
您似乎需要使用
NextToken
进行迭代
以下是摘录自:
您似乎需要使用
NextToken
进行迭代
以下是摘录自:
谢谢你,约翰,我用这个解决了这个问题。但我会把你的回答也记下来。谢谢你的回复。谢谢约翰,我用这个来解决这个问题:。但我会把你的回答也记下来。谢谢你的回复。
next_token = '' # variable to hold the pagination token
while next_token is not None:
results = pricing.get_products(..., NextToken=next_token)
next_token = results['NextToken']