Last active
July 7, 2019 19:06
-
-
Save heffo42/f6f8b5495b7a42832ab05ef3a1deb04b to your computer and use it in GitHub Desktop.
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
#tweets is the html data as a bs4 (beautifulsoup) object | |
def writeTweets(tweets): | |
newTweetRecords = [] | |
for tweet in tweets: | |
try: | |
if tweet.find("a", {"class" : "js-action-profile-promoted"}): | |
continue | |
text = tweet.find("p", {"class" : "tweet-text"}).get_text() | |
date = tweet.find("span", {"class" : "_timestamp"})["data-time-ms"] | |
tweetId = tweet['data-item-id'] | |
tweetRecord = {"text" : text, "date" : date, "tweetId" : tweetId} | |
newTweetRecords.append(tweetRecord) | |
except: | |
print("Unable to process tweet") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment