Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
send_tweets_to_spark
def send_tweets_to_spark(http_resp, tcp_connection):
for line in http_resp.iter_lines():
try:
full_tweet = json.loads(line)
datetime = full_tweet['created_at'][:20]
tweet = full_tweet['text']
print (f"---------------{datetime}--------------------------")
print(tweet)
tcp_connection.send(bytes(tweet, "utf-8"))
except:
e = sys.exc_info()[0]
print("Error : %s" % e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment