来自外部REST API的AWS Glue作业消耗数据

编程入门 行业动态 更新时间:2024-10-09 09:17:17
本文介绍了来自外部REST API的AWS Glue作业消耗数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试创建一个工作流,其中AWS Glue ETL作业将从外部REST API而非S3或任何其他AWS内部源中提取JSON数据.那有可能吗?有人吗请帮忙!

I'm trying to create a workflow where AWS Glue ETL job will pull the JSON data from external REST API instead of S3 or any other AWS-internal sources. Is that even possible? Anyone does it? Please help!

推荐答案

是的,我确实从REST API(例如Twitter,FullStory,Elasticsearch等)中提取数据.通常,我确实使用Python Shell作业进行提取,因为它们是更快(冷启动相对较小).完成后,它会触发一个Spark类型的作业,该作业仅读取我需要的json项.我使用请求pyhton库.

Yes, I do extract data from REST API's like Twitter, FullStory, Elasticsearch, etc. Usually, I do use the Python Shell jobs for the extraction because they are faster (relatively small cold start). When is finished it triggers a Spark type job that reads only the json items I need. I use the requests pyhton library.

为了将数据保存到S3中,您可以执行以下操作

In order to save the data into S3 you can do something like this

import boto3 import json # Initializes S3 client s3 = boto3.resource('s3') tweets = [] //Code that extracts tweets from API tweets_json = json.dumps(tweets) obj = s3.Object("my-tweets", "tweets.json") obj.put(Body=data)

更多推荐

来自外部REST API的AWS Glue作业消耗数据

本文发布于:2023-11-28 06:07:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641233.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   消耗   数据   API   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!