检查URL运行状况的Python Lambda

检查URL运行状况的Python Lambda,python,lambda,Python,Lambda,我已经编写了一个小函数,但当我执行它时,只有列表中的最后一个URL被传递给函数。请纠正我的错误 def lambda_handler(event, context): websiteURL = ['https://example1.com','https://example2.com','https://example3.com'] topicArnCode = 'arn:aws:sns:ap-southeast-1:123:sample' for x in websit

我已经编写了一个小函数,但当我执行它时,只有列表中的最后一个URL被传递给函数。请纠正我的错误

def lambda_handler(event, context):
    websiteURL = ['https://example1.com','https://example2.com','https://example3.com']
    topicArnCode = 'arn:aws:sns:ap-southeast-1:123:sample'
    for x in websiteURL:
        print (x)
    r = requests.get(x,verify=False)
    print (r)
    if r.status_code == 200:
        return 'Website is alive!'
    else:
        sns_client = boto3.client('sns')
        sns_client.publish(
        TopicArn = topicArnCode,
        Subject = 'Website is not reachable ' + x,
        Message = 'Website: ' + x + ' is down\n')
        return 'Website is dead'

这是一个缩进打字错误:

def lambda_handler(event, context):
    websiteURL = ['https://example1.com','https://example2.com','https://example3.com']
    topicArnCode = 'arn:aws:sns:ap-southeast-1:123:sample'
    for x in websiteURL:
        print (x)
        r = requests.get(x,verify=False)
        print (r)
        if r.status_code == 200:
            print('Website is alive!')
        else:
            sns_client = boto3.client('sns')
            sns_client.publish(
            TopicArn = topicArnCode,
            Subject = 'Website is not reachable ' + x,
            Message = 'Website: ' + x + ' is down\n')
            print('Website is dead')