Python Lambda检查URL运行状况

时间:2019-11-18 04:45:57

标签: 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 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'

1 个答案:

答案 0 :(得分:2)

这是一个缩进错字:

'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,

        ...

        'Str' => Illuminate\Support\Str::class
]