JosePezantes commited on
Commit
ebb8e7b
·
1 Parent(s): dd24018

Correccciones de validaciones

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -108,28 +108,33 @@ def run():
108
  submit_button = myform.form_submit_button(label='Analizar')
109
 
110
  if submit_button:
111
-
112
- if number_of_tweets <= 0:
113
- st.error("Por favor, ingrese un número de tweets mayor a 0.")
114
- return
115
 
116
  if (filtro=='Término'):
117
 
118
  if not search_words:
119
  st.error("Campo vacío. Por favor, ingrese un término o usuario.")
120
  return
 
 
 
121
  new_search = search_words + " -filter:retweets"
122
  tweets =tw.Cursor(api.search_tweets,q=new_search,lang="es",tweet_mode="extended").items(number_of_tweets)
123
 
124
  elif (filtro=='Usuario'):
125
 
126
- if not search_words.startswith('@'):
127
- st.error("Por favor, ingrese un usuario válido, iniciando con @")
128
- return
129
  try:
130
  if not search_words:
131
  st.error("Campo vacío. Por favor, ingrese un usuario.")
132
- return
 
 
 
 
 
 
 
 
 
133
  tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended",count=number_of_tweets)
134
 
135
  except tw.errors.NotFound:
 
108
  submit_button = myform.form_submit_button(label='Analizar')
109
 
110
  if submit_button:
 
 
 
 
111
 
112
  if (filtro=='Término'):
113
 
114
  if not search_words:
115
  st.error("Campo vacío. Por favor, ingrese un término o usuario.")
116
  return
117
+ if number_of_tweets <= 0:
118
+ st.error("Por favor, ingrese un número de tweets mayor a 0.")
119
+ return
120
  new_search = search_words + " -filter:retweets"
121
  tweets =tw.Cursor(api.search_tweets,q=new_search,lang="es",tweet_mode="extended").items(number_of_tweets)
122
 
123
  elif (filtro=='Usuario'):
124
 
 
 
 
125
  try:
126
  if not search_words:
127
  st.error("Campo vacío. Por favor, ingrese un usuario.")
128
+ return
129
+
130
+ if not search_words.startswith('@'):
131
+ st.error("Por favor, ingrese un usuario válido, iniciando con @")
132
+ return
133
+
134
+ if number_of_tweets <= 0:
135
+ st.error("Por favor, ingrese un número de tweets mayor a 0.")
136
+ return
137
+
138
  tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended",count=number_of_tweets)
139
 
140
  except tw.errors.NotFound: