本文整理汇总了Python中models.Tweet.is_Petralha方法的典型用法代码示例。如果您正苦于以下问题:Python Tweet.is_Petralha方法的具体用法?Python Tweet.is_Petralha怎么用?Python Tweet.is_Petralha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tweet
的用法示例。
在下文中一共展示了Tweet.is_Petralha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tweets
# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import is_Petralha [as 别名]
def get_tweets(request):
consumer_key = keys.CONSUMER_KEY
consumer_secret = keys.CONSUMER_SECRET
access_token = keys.ACCESS_TOKEN
access_token_secret = keys.ACCESS_TOKEN_SECRET
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
coxinha_words = ['AvanteTemer', 'ForaDilma', 'petralha', 'ForaLula', 'TchauQuerida', 'Petista', 'Esquerdista']
petralha_words = ['NãoVaiTerGolpe', 'ForaTemer', 'GloboGolpista', 'DilmaFica', 'FicaDilma', 'TemerJamais', 'VoltaDilma', 'VaiTerLuta', 'Golpista']
#potential_words = ['Dilma', 'Lula', 'Temer', 'Cunha', 'Aécio', 'Moro', 'Golpe', 'Oposição', 'Impeachment', 'governo', 'democracia', 'político', 'política', 'operação', 'Corrupção', 'Corrupto', 'Jucá', 'cpiminc', 'Esquerda', 'Sarney']
#potential_words = ['Comunista', 'Comuna', 'esquerdopata', 'Jucá', 'Direita', 'Ministro']
#potential_words = ['Petralhas', 'PassaDilma', 'Protesto', 'Protestos', 'Ministros']
# is_Petralha = False
# for query in coxinha_words:
# for status in tweepy.Cursor(api.search, q=query + '&place:d9d978b087a92583').items():
#
# if status.geo != None:
# print "Tweet:", status.text.encode('utf8')
# print "Geo:", status.geo['coordinates']
# print "//////////////////"
# try:
# tweet = Tweet()
# tweet.is_Petralha = is_Petralha
# tweet.text = status.text.encode('utf-8')
# tweet.lat = status.geo['coordinates'][0]
# tweet.lng = status.geo['coordinates'][1]
# tweet.save()
# print "ADDED"
# except IntegrityError as e:
# print e.message
#
is_Petralha = True
for query in petralha_words:
for status in tweepy.Cursor(api.search, q=query + '&place:d9d978b087a92583').items():
if status.geo != None:
print "Tweet:", status.text.encode('utf8')
print "Geo:", status.geo['coordinates']
print "//////////////////"
try:
tweet = Tweet()
tweet.is_Petralha = is_Petralha
tweet.text = status.text.encode('utf-8')
tweet.lat = status.geo['coordinates'][0]
tweet.lng = status.geo['coordinates'][1]
tweet.save()
print "ADDED"
except IntegrityError as e:
print e.message
#
# for query in potential_words:
# for status in tweepy.Cursor(api.search, q=query + '&place:d9d978b087a92583').items():
#
# if status.geo != None:
# print "Tweet:", status.text.encode('utf8')
# print "Geo:", status.geo['coordinates']
# print "//////////////////"
# try:
# tweet = Tweets();
# tweet.text = status.text.encode('utf-8')
# tweet.lat = status.geo['coordinates'][0]
# tweet.lng = status.geo['coordinates'][1]
# tweet.save()
# print "ADDED POTENTIAL"
# except IntegrityError as e:
# print e.message
print "That's end"
return render(request, 'coxinhaoupetralha/index.html', {})