Spot 实例 "frequency of interruption" 比率如期获得

Spot Instance "frequency of interruption" ratio get as scheduled

AWS 在没有 API 的页面上宣布 "frequency of interruption":https://aws.amazon.com/ec2/spot/instance-advisor/

我需要按计划在弗吉尼亚州获得所有类型(255 件)。我该怎么做?

我通过使用 selenium 和 Python 抓取页面解决了这个问题。您可以 运行 docker 中的以下脚本,它将创建 aws-spot-instance.txt 密码。

你可以更改区域,在脚本中是region = 'US East (N. Virginia)'

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("--headless") # Runs Chrome in headless mode.
options.add_argument('--no-sandbox') # # Bypass OS security model
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument("--disable-extensions")
options.add_argument('--disable-gpu')

region = 'US East (N. Virginia)'

driver = webdriver.Chrome(chrome_options=options)
driver.get("https://aws.amazon.com/ec2/spot/instance-advisor")
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".dropdown-container.aws-dropdown-region.dropdown-built")))
element.click()
driver.find_element_by_xpath("//span[text()='%s']" %region).click()
driver.find_element_by_css_selector(".aws-spot-advisor-button-expand.button").click()

table_data = driver.find_element_by_css_selector(".table.table-striped").text
fw = open('aws-spot-instance.txt', "w")
fw.write(table_data)
fw.close()

将此脚本保存为 aws.py 和 运行 以下命令:

docker pull gunesmes/python-selenium-behave-page-object-docker
docker run --rm --name aws -v $PWD:/project gunesmes/python-selenium-behave-page-object-docker bash -c "python3 aws.py"