Karthikeyan KR
Karthikeyan KR

Reputation: 1174

Wget in AWS Lambda returns none

I tried a python code to call wget, but it returns nothing. Is there wget enabled in Lambda?

My sample code:

def lambda_handler(event, context):
    import os 
    f = os.popen("wget -qO- --timeout=30 --tries=1 google.com")
    a = []
    for line in f.readlines(): 
       a.append(line)
    return a

But it returns an empty list.

Upvotes: 0

Views: 3351

Answers (1)

Niroshan Ranapathi
Niroshan Ranapathi

Reputation: 3047

lets try to use urllib instance of wget.

import urllib.request
local_filename, headers = urllib.request.urlretrieve('http://google.com')
f = open(local_filename)

Upvotes: 1

Related Questions