try:
tweets = self.api.home_timeline(tweet_mode='extended', count=200)
except:
- print "Exception while fetching tweets!"
+ print("Exception while fetching tweets!")
return False
for tweet in tweets:
author = tweet.author.name
return True
def shuffle_tweets(self):
- authors = self.tweets_by_author.keys()
+ authors = list(self.tweets_by_author.keys())
author = random.choice(authors)
handle = self.handles_by_author[author]
tweets = self.tweets_by_author[author]
already_seen = set()
- f = file_writer.file_writer('twitter_5_none.html')
- f.write('<TABLE WIDTH=96%><TR><TD WIDTH=80%>')
+ f = file_writer.file_writer('twitter_10_none.html')
+ f.write('<TABLE WIDTH=96%><TR><TD WIDTH=86%>')
f.write('<H2>%s (@%s)</H2></TD>\n' % (author, handle))
f.write('<TD ALIGN="right" VALIGN="top">')
f.write('<IMG SRC="twitter.png" WIDTH=42></TD></TR></TABLE>\n')
(not self.filter.contains_bad_words(text))):
already_seen.add(text)
text = self.linkify(text)
- f.write(u'<LI><B>%s</B>\n' % text)
+ f.write('<LI><B>%s</B>\n' % text)
count += 1
length += len(text)
if count > 3 or length > 270:
#x = t.linkify(x)
#print x
if t.fetch_tweets() == 0:
- print "Error fetching tweets, none fetched."
+ print("Error fetching tweets, none fetched.")
else:
t.shuffle_tweets()