def index(): if (request.method == 'POST'): query1 = request.form.get('query') api = TwitterClient() tweets = api.get_tweets(query=query1, count=200) # picking positive tweets from tweets ptweets = [tweet for tweet in tweets if tweet['sentiment'] == 'positive'] # percentage of positive tweets posper = 100 * len(ptweets) / len(tweets) # picking negative tweets from tweets ntweets = [tweet for tweet in tweets if tweet['sentiment'] == 'negative'] negper = 100 * len(ntweets) / len(tweets) # percentage of neutral tweets neuper = 100 * (len(tweets) - len(ntweets) - len(ptweets)) / len(tweets) resultdict = { "Positive tweets percentage": int(posper), "negative tweets percentage ": int(negper), "neutral tweets percentage": int(neuper) } return render_template('index.html', result=resultdict, ip=query1, pt=ptweets, nt=ntweets)
def submit(): keyword = request.form['keyword'] count = request.form['count'] # Get the tweets try: api = TwitterClient() tweets = api.get_tweets(query = keyword, count = count) positive_tweets = [tweet for tweet in tweets if tweet['sentiment'] == 'positive'] positive_tweets_percentage = round(len(positive_tweets)/len(tweets)*100, 2) negative_tweets = [tweet for tweet in tweets if tweet['sentiment'] == 'negative'] negative_tweets_percentage = round(len(negative_tweets)/len(tweets)*100, 2) neutral_percentage = round((len(tweets) - len(positive_tweets) - len(negative_tweets))/len(tweets)*100, 2) context = { 'ptweets': positive_tweets[:5], 'ntweets': negative_tweets[:5], 'ppercent': positive_tweets_percentage, 'npercent': negative_tweets_percentage, 'neutral': neutral_percentage } return render_template("results.html", context = context) except Exception as e: return str(e)
def count_quotes(self): twc = TwitterClient() n_citacoes = [] for _, row in self.df.iterrows(): log.info("Fetching quotes for: {}".format(row['track_name'])) n_citacoes.append(twc.count(row['track_name'])) self.df['n_citacoes'] = n_citacoes columns = [ 'id', 'track_name', 'n_citacoes', 'size_bytes', 'price', 'prime_genre' ] self.df = self.df[columns]
def twitter(): firebase = Firebase("Twitter") docs = firebase.get_stream() for doc in docs: doc_id = doc.id doc = doc.to_dict() twitter_client = TwitterClient(doc["screen_name"]) unseen_tweets = twitter_client.get_user_timeline_unseen_tweets(doc["last_seen_id"]) if unseen_tweets: twitter_client.favorite_and_retweet(unseen_tweets, filter_word=doc.get("filter_word", "")) doc["last_seen_id"] = str(unseen_tweets[0].id) firebase.update(doc_id, doc)
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@LynusMascot') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@Kikokiki19') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@SuvarnaVaidya3') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@kurkute') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# -*- coding: utf-8 -*- """ Created on Mon Jun 17 14:31:38 2019 @author: Verma """ import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient(query='data science') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower()))
from twitter import TwitterClient import json def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] def parse_env_json(): with open(".env.json") as f: return json.load(f) app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('Donald Trump', **parse_env_json()) @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query)
# -*- coding: utf-8 -*- """ Created on Sat Jan 18 20:28:50 2020 @author: Shiv kumar """ import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@yum_dude') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment')
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) api = TwitterClient('@Djokarara') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os from flask import Flask, jsonify, redirect, render_template, url_for, request from twitter import TwitterClient import praw import tweepy from analysis import subredditAnalysis, userTweetAnalysis, searchTweetAnalysis, customTextAnalysis # Configure application app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@codedatt') # Ensure templates are auto-reloaded app.config["TEMPLATES_AUTO_RELOAD"] = True # To avoid caching of static files app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 # Render routes @app.route('/') def index(): return (render_template("index.html")) @app.route('/reddit') def reddit(): return render_template("reddit-main.html")
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@GGodage') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# Server import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client api = TwitterClient('@NagarajmvRahul') def str_to_bool(s): return s.lower() in ['yes', 'true', 1, 't'] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(str_to_bool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(str_to_bool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@crs_macedo') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# -*- coding: utf-8 -*- import requests import json from requests_oauthlib import OAuth1Session from twitter import TwitterClient consumer_key = '' consumer_secret = '' access_token = '' access_secret_token = '' twitter_client = TwitterClient(consumer_key, consumer_secret, access_token, access_secret_token) for tweet in twitter_client.get_tweets('naruto', n=100, lang='pt-br'): print(tweet['text'])
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@abdullahfachmi') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@Gauravkanwar07') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = rhnvrm <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@suwungtandon') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@gofornaman') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
# author = piyushvarshney <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@PrivateCode3') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import requests, time, os, math, threading from datetime import datetime, timedelta, timezone, time as dt_time from dateutil import parser from dotenv import load_dotenv from team import Team from image import build_image from twitter import TwitterClient from sms import SMSClient from db import DatabaseConnector from prediction import Prediction from utils import headers twitter_client = TwitterClient() sms_client = SMSClient() db_connector = DatabaseConnector() load_dotenv() dirname = os.path.dirname(__file__) LEAGUE_ID = os.getenv("LEAGUE_ID") LEAGUE_ID_PREV = os.getenv("LEAGUE_ID_PREV") def get_utc_timestamp(): return int(datetime.utcnow().timestamp()) def current_utc_day(): return datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0) def seconds_to(time):
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@anishsg3') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) api = TwitterClient('@adambfad') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) resultSets = api.get_tweets() return jsonify({'resultSet': resultSets, 'count': len(resultSets)})
# author = piyushvarshney <*****@*****.**> import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@yenhsravhsuyip') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@Sirajology') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() return jsonify({'data': tweets, 'count': len(tweets)})
import os, logging from flask import Flask, request, render_template, jsonify from twitter import TwitterClient logging.basicConfig( filename='logging.log', format='%(levelname)s - %(asctime)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO) app = Flask(__name__) api = TwitterClient('Data') # abc xyz dgfcgfv jfhjhsdfjhdfnbgjk hjghhgbhgb logger = logging.getLogger(__name__) def strtobool(v): return v.lower() in ['yes', 'true', 't', 'l'] @app.route('/') def index(): logger.info('** Home page accessed **') logger.debug('** This is not debug **') return render_template('index.html') @app.route('/tweets')
import os from flask import Flask, request, render_template, jsonify from twitter import TwitterClient app = Flask(__name__) # Setup the client <query string, retweets_only bool, with_sentiment bool> api = TwitterClient('@AnoopBenny5') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('indexa.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) with_sentiment = request.args.get('with_sentiment') api.set_with_sentiment(strtobool(with_sentiment.lower())) query = request.args.get('query') api.set_query(query) st = request.args.get('st') api.set_styr(st) en = request.args.get('en')
from flask import Flask, request, render_template, jsonify from twitter import TwitterClient import json app = Flask(__name__) api = TwitterClient('') def strtobool(v): return v.lower() in ["yes", "true", "t", "1"] @app.route('/') def index(): return render_template('index.html') @app.route('/tweets') def tweets(): retweets_only = request.args.get('retweets_only') api.set_retweet_checking(strtobool(retweets_only.lower())) query = request.args.get('query') api.set_query(query) tweets = api.get_tweets() dados = jsonify({'data': tweets, 'count': len(tweets)}) return dados