Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,18 @@ import time
|
|
| 6 |
from pytrends.request import TrendReq
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
import seaborn as sns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
st.set_page_config(page_title="Trend Analysis", page_icon="🔍")
|
| 11 |
|
| 12 |
# Setup PyTrends dengan delay untuk menghindari rate limiting
|
| 13 |
-
pytrends = TrendReq(hl='en-US', tz=360)
|
| 14 |
|
| 15 |
def get_trend_data(keywords, timeframe):
|
| 16 |
pytrends.build_payload(keywords, cat=0, timeframe=timeframe)
|
|
|
|
| 6 |
from pytrends.request import TrendReq
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
import seaborn as sns
|
| 9 |
+
import random
|
| 10 |
+
|
| 11 |
+
user_agents = [
|
| 12 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
| 13 |
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
|
| 14 |
+
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0)"
|
| 15 |
+
]
|
| 16 |
|
| 17 |
st.set_page_config(page_title="Trend Analysis", page_icon="🔍")
|
| 18 |
|
| 19 |
# Setup PyTrends dengan delay untuk menghindari rate limiting
|
| 20 |
+
pytrends = TrendReq(hl='en-US', tz=360, user_agent=random.choice(user_agents))
|
| 21 |
|
| 22 |
def get_trend_data(keywords, timeframe):
|
| 23 |
pytrends.build_payload(keywords, cat=0, timeframe=timeframe)
|