gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 12:01:50 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com