🐍
【Python】Lambdaで外部APIを使う
requestsは別途installしてimportする必要があるのでurllib3を使う
例
import json
import urllib3
from urllib3 import PoolManager
def req():
url = f"https://sample.com"
http = urllib3.PoolManager()
response = http.request('GET', url)
decoded_data = response.data.decode('utf-8')
json_data = json.loads(decoded_data)
return json_data
Discussion