podsnigame commited on
Commit
c70e931
·
1 Parent(s): 665589f
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -2,7 +2,8 @@ import streamlit as st
2
  import snscrape.modules.twitter as sntwitter
3
  import pandas as pd
4
  import plotly.express as px
5
- import base64
 
6
 
7
 
8
  st.set_page_config(page_title="Scraping Twitter")
@@ -73,14 +74,14 @@ if st.button('Scrape Tweets'):
73
  # Download CSV
74
  if len(tweets_df) > 0:
75
  csv = tweets_df.to_csv(index=False)
76
- b64 = base64.b64encode(csv.encode()).decode()
77
  filename = f'tweets_{query.replace(" ", "_")}.csv'
78
  href = f'<a href="data:file/csv;base64,{b64}" download="{filename}">Download CSV</a>'
79
  st.markdown(href, unsafe_allow_html=True)
80
 
81
  if len(tweets_df) > 0:
82
  txt = "\n\n".join(tweets_df['Text'].tolist())
83
- b64 = base64.b64encode(txt.encode()).decode()
84
  txt_filename = f"{query}_tweets.txt"
85
  txt_href = f'<a href="data:file/txt;base64,{b64}" download="{txt_filename}">Download TXT</a>'
86
  st.markdown(txt_href, unsafe_allow_html=True)
 
2
  import snscrape.modules.twitter as sntwitter
3
  import pandas as pd
4
  import plotly.express as px
5
+ # import base64
6
+ import pybase64
7
 
8
 
9
  st.set_page_config(page_title="Scraping Twitter")
 
74
  # Download CSV
75
  if len(tweets_df) > 0:
76
  csv = tweets_df.to_csv(index=False)
77
+ b64 = pybase64.b64encode(csv.encode()).decode()
78
  filename = f'tweets_{query.replace(" ", "_")}.csv'
79
  href = f'<a href="data:file/csv;base64,{b64}" download="{filename}">Download CSV</a>'
80
  st.markdown(href, unsafe_allow_html=True)
81
 
82
  if len(tweets_df) > 0:
83
  txt = "\n\n".join(tweets_df['Text'].tolist())
84
+ b64 = pybase64.b64encode(txt.encode()).decode()
85
  txt_filename = f"{query}_tweets.txt"
86
  txt_href = f'<a href="data:file/txt;base64,{b64}" download="{txt_filename}">Download TXT</a>'
87
  st.markdown(txt_href, unsafe_allow_html=True)