def get_demand_price(aws_region, instance_type):
"""Get AWS instance demand price.
>>> print(get_demand_price('us-east-1', 'm4.2xlarge'))
"""
soup = BeautifulSoup(urlopen(EC2_INSTANCES_INFO_URL), 'html.parser')
table = soup.find('table', {'id': 'data'})
row = table.find(id=instance_type)
td = row.find('td', {'class': 'cost-ondemand-linux'})
region_prices = json.loads(td['data-pricing'])
return float(region_prices[aws_region])
评论列表
文章目录