Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added twitter trends #16

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
CLOUDAMQP_URL="amqp://guest:[email protected]:5672/my_vhost"
CLOUDAMQP_URL="amqp://guest:[email protected]:5672/my_vhost"
TWITTER_CONSUMER_KEY=5dw6xPx1lqkGBTvenOJImIGIG
TWITTER_CONSUMER_SECRET=Phdq6MSAi3oA0QMK6WODzittQFaPZZPaEKm42VmcTidtWGnrFJ
TWITTER_ACCESS_TOKEN=270269016-nK7o34Fdnp4XYfVLP1oNHc1Q3lAmkMaH49JVuTHN
TWITTER_ACCESS_TOKEN_SECRET=PadEZhRfnOBfRMsY22CKWe9mO0MSGyUw9VkqhuSVZZ3h8
TWITTER_LOCATION_ID=44418
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
__pycache__
venv
venv
.env
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ RUN su -c "pip3 install html5lib"
RUN su -c "pip3 install tomd"
RUN su -c "pip3 install pandoc"
RUN su -c "pip3 install pytrends"
RUN su -c "pip3 install tweepy"
RUN su -c "pip3 install python-decouple"
RUN su -c "pip3 install pypandoc"
RUN su -c "pip3 install hypercorn"
RUN su -c "pip3 install google-search-results"
Expand Down
6 changes: 6 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CLOUDAMQP_URL="amqp://guest:[email protected]:5672/my_vhost"
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''
TWITTER_ACCESS_TOKEN = ''
TWITTER_ACCESS_TOKEN_SECRET = ''
TWITTER_LOCATION_ID = '1'
17 changes: 16 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
yesterday = yesterday.strftime('%m-%d-%Y')

from classes.TextSummarizer import *
from decouple import config

import tweepy
from decouple import config

# Twitter trends
auth = tweepy.OAuthHandler(config("TWITTER_CONSUMER_KEY"), config("TWITTER_CONSUMER_SECRET"))
auth.set_access_token(config("TWITTER_ACCESS_TOKEN"), config("TWITTER_ACCESS_TOKEN_SECRET"))
api = tweepy.API(auth)

WOEID = config("TWITTER_LOCATION_ID")


tags_metadata = [
Expand Down Expand Up @@ -128,11 +139,15 @@ async def root():

google_trends = pytrends.realtime_trending_searches(pn='GB')
trends = pytrends.realtime_trending_searches(pn='GB')

twitter_trends = api.get_place_trends(WOEID)

return {

"data": {
"newspaper": newspaper_hot_trends,
"google": trends["title"].tolist()
"google": trends["title"].tolist(),
"twitter": twitter_trends,
}
}

Expand Down