This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spark = SparkSession.builder\ | |
.master("local")\ | |
.appName("Structured Streaming - Twitter Sentiment")\ | |
.getOrCreate() | |
pythonSchema = StructType() \ | |
.add("id", StringType(), True) \ | |
.add("tweet", StringType(), True) \ | |
.add("ts", StringType(), True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create kinesis client connection | |
kinesis_client = boto3.client('kinesis', | |
region_name='', # enter the region | |
aws_access_key_id='', # fill your AWS access key id | |
aws_secret_access_key='') # fill you aws secret access key | |
# create instance of the tweepy tweet stream listener | |
listener = TweetStreamListener() | |
# set twitter keys/tokens | |
auth = OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) |