tx3bas commited on
Commit
355513b
verified
1 Parent(s): d72c75e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import streamlit as st
2
  import requests
3
  import pandas as pd
4
- import pyperclip
5
 
6
  def fetch_data(keyword, location, lang):
7
  url = f"https://google-keyword-insight1.p.rapidapi.com/keysuggest?keyword={keyword}&location={location}&lang={lang}"
@@ -24,9 +23,6 @@ def round_to_nearest_five_cents(value):
24
  def round_trend_to_percentage(value):
25
  return f'{round(value)} %'
26
 
27
- def convert_df_to_string(df):
28
- return df.to_string(index=False)
29
-
30
  st.title('B煤squeda de Palabras Clave')
31
 
32
  keyword = st.text_input('Palabra clave:', placeholder='Ingrese la b煤squeda', key='keyword')
@@ -51,11 +47,18 @@ if st.button('Buscar'):
51
  df.sort_values(by='Volumen', ascending=False, inplace=True)
52
  st.table(df)
53
 
54
- if st.button('Copiar Resultados'):
55
- df_string = convert_df_to_string(df)
56
- pyperclip.copy(df_string)
57
- st.success('Resultados copiados al portapapeles.')
58
- else:
59
- st.write('No se encontraron resultados.')
 
 
 
 
 
 
 
60
 
61
  # Run the app using the command: streamlit run app.py
 
1
  import streamlit as st
2
  import requests
3
  import pandas as pd
 
4
 
5
  def fetch_data(keyword, location, lang):
6
  url = f"https://google-keyword-insight1.p.rapidapi.com/keysuggest?keyword={keyword}&location={location}&lang={lang}"
 
23
  def round_trend_to_percentage(value):
24
  return f'{round(value)} %'
25
 
 
 
 
26
  st.title('B煤squeda de Palabras Clave')
27
 
28
  keyword = st.text_input('Palabra clave:', placeholder='Ingrese la b煤squeda', key='keyword')
 
47
  df.sort_values(by='Volumen', ascending=False, inplace=True)
48
  st.table(df)
49
 
50
+ # Convert DataFrame to CSV
51
+ csv = df.to_csv(index=False)
52
+
53
+ st.download_button(
54
+ label="Descargar resultados como CSV",
55
+ data=csv,
56
+ file_name='resultados.csv',
57
+ mime='text/csv',
58
+ )
59
+
60
+ st.code(df.to_string(index=False), language='text')
61
+
62
+ st.write('Selecciona el texto arriba y c贸pialo manualmente si es necesario.')
63
 
64
  # Run the app using the command: streamlit run app.py