amazon-web-services - 竞价型实例 “frequency of interruption”比例按计划获取

标签 amazon-web-services kubernetes qa testautomationfx

AWS在没有API的页面上在此处宣布“中断频率”:https://aws.amazon.com/ec2/spot/instance-advisor/
我需要按计划获取弗吉尼亚州的所有类型(255件)。我怎样才能做到这一点?

最佳答案

我通过使用Selenium和Python爬行页面来解决它。您可以在docker中运行以下脚本,它将在Pwd中创建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"

enter image description here

关于amazon-web-services - 竞价型实例 “frequency of interruption”比例按计划获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60543583/

相关文章:

amazon-web-services - AWS SQS : Delay making available a message that failed to process

amazon-web-services - 在不使用 Cloudfront 或 Elastic Load Balancing 的 AWS EC2 实例上安装 SSL 证书

amazon-web-services - 将设备状态的副本保留在事物影子和 DynamoDB 等数据库中是否是最佳实践?

kubernetes - 使用kubectx的kubectl “error: You must be logged in to the server (Unauthorized)”,如果直接使用相同的配置则没有错误

javascript - 库伯内特斯 : Pause main script while keeping pod alive

qa - 您使用什么工具来查看您的用户在哪里挣扎/看到您的网站的错误?

node.js - Google服务帐户: The API returned an error: TypeError: source. hasOwnProperty在一小时后不再是一个函数

javascript - Kubernetes 容器, "canceling"云存储通知

testing - 用于记录 Action 序列的视频或幻灯片捕获工具会导致错误

api - 您使用什么工具来测试您的公共(public) REST API?