我们使用AWS Cloudwatch Syntetic Canary通过发送GET请求来测试应用程序URL的可用性。 现在,我想监视一个URL,但这个URL需要一个密钥ID进行身份验证,才能得到200个响应。 以下是对URL的简单get请求,无需验证:
from aws_synthetics.selenium import synthetics_webdriver as syn_webdriver
from aws_synthetics.common import synthetics_logger as logger
def main():
url = "http://google.com"
# Set screenshot option
takeScreenshot = True
browser = syn_webdriver.Chrome()
browser.get(url)
if takeScreenshot:
browser.save_screenshot("loaded.png")
response_code = syn_webdriver.get_http_response(url)
if not response_code or response_code < 200 or response_code > 299:
raise Exception("Failed to load page!")
logger.info("Canary successfully executed")
def handler(event, context):
# user defined log statements using synthetics_logger
logger.info("Selenium Python heartbeat canary")
return main()
如何使用python Selenium发出Get请求并提供用于身份验证的密钥? 多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐