Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
import base64
|
5 |
-
import io
|
6 |
|
7 |
def get_backlinks(api_login, api_key, target_url, filters):
|
8 |
# Encoding credentials
|
@@ -97,15 +96,15 @@ reset_button = st.sidebar.button("Reset")
|
|
97 |
if generate_button and target_url:
|
98 |
df = get_backlinks(api_login, api_key, target_url, filters)
|
99 |
if df is not None:
|
100 |
-
#
|
|
|
|
|
|
|
|
|
101 |
with col2:
|
102 |
st.header("Output")
|
103 |
-
|
104 |
-
|
105 |
-
# Convert DataFrame to CSV
|
106 |
-
csv = df.to_csv(index=False).encode('utf-8')
|
107 |
-
b64 = base64.b64encode(csv).decode() # Convert bytes to base64 encoded string
|
108 |
-
download_link = st.download_button(label="Download data as CSV", data=b64, file_name='backlinks_data.csv', mime='text/csv')
|
109 |
|
110 |
# Reset functionality
|
111 |
if reset_button:
|
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
import base64
|
|
|
5 |
|
6 |
def get_backlinks(api_login, api_key, target_url, filters):
|
7 |
# Encoding credentials
|
|
|
96 |
if generate_button and target_url:
|
97 |
df = get_backlinks(api_login, api_key, target_url, filters)
|
98 |
if df is not None:
|
99 |
+
# Convert DataFrame to CSV
|
100 |
+
csv = df.to_csv(index=False)
|
101 |
+
# Convert CSV to a string
|
102 |
+
b64 = base64.b64encode(csv.encode()).decode()
|
103 |
+
href = f'<a href="data:file/csv;base64,{b64}" download="backlinks.csv">Download CSV file</a>'
|
104 |
with col2:
|
105 |
st.header("Output")
|
106 |
+
# Display the download link
|
107 |
+
st.markdown(href, unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
108 |
|
109 |
# Reset functionality
|
110 |
if reset_button:
|