Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
-
from client import RestClient
|
5 |
-
import io
|
6 |
import base64
|
7 |
-
import requests
|
8 |
|
9 |
# Function to call the DataForSEO API with Basic Authentication
|
10 |
def get_backlinks(api_login, api_key, target_url, filters):
|
@@ -39,18 +36,6 @@ def get_backlinks(api_login, api_key, target_url, filters):
|
|
39 |
st.sidebar.title("DataForSEO API Parameters")
|
40 |
api_login = st.sidebar.text_input("API Login", value="[email protected]")
|
41 |
api_key = st.sidebar.text_input("API Key", type="password")
|
42 |
-
generate_button = st.sidebar.button("Generate All")
|
43 |
-
reset_button = st.sidebar.button("Reset")
|
44 |
-
|
45 |
-
# Make sure to pass api_login to the get_backlinks function
|
46 |
-
if generate_button and target_url:
|
47 |
-
data = get_backlinks(api_key, target_url, filters)
|
48 |
-
if data:
|
49 |
-
df = pd.DataFrame(data)
|
50 |
-
csv = df.to_csv(index=False)
|
51 |
-
b64 = base64.b64encode(csv.encode()).decode()
|
52 |
-
href = f'<a href="data:file/csv;base64,{b64}" download="backlinks.csv">Download CSV file</a>'
|
53 |
-
st.markdown(href, unsafe_allow_html=True)
|
54 |
|
55 |
# Filters
|
56 |
url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)")
|
@@ -76,14 +61,13 @@ col1, col2 = st.columns(2)
|
|
76 |
|
77 |
with col1:
|
78 |
st.header("Input")
|
79 |
-
target_url = st.text_input("Enter the target URL")
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
# [Your code for displaying output]
|
84 |
|
85 |
# Generate CSV and download button
|
86 |
-
if generate_button and target_url:
|
87 |
data = get_backlinks(api_login, api_key, target_url, filters)
|
88 |
if data:
|
89 |
df = pd.DataFrame(data)
|
@@ -92,7 +76,10 @@ if generate_button and target_url:
|
|
92 |
href = f'<a href="data:file/csv;base64,{b64}" download="backlinks.csv">Download CSV file</a>'
|
93 |
st.markdown(href, unsafe_allow_html=True)
|
94 |
|
|
|
|
|
|
|
|
|
95 |
# Reset functionality
|
96 |
if reset_button:
|
97 |
-
st.experimental_rerun()
|
98 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import requests
|
|
|
|
|
4 |
import base64
|
|
|
5 |
|
6 |
# Function to call the DataForSEO API with Basic Authentication
|
7 |
def get_backlinks(api_login, api_key, target_url, filters):
|
|
|
36 |
st.sidebar.title("DataForSEO API Parameters")
|
37 |
api_login = st.sidebar.text_input("API Login", value="[email protected]")
|
38 |
api_key = st.sidebar.text_input("API Key", type="password")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Filters
|
41 |
url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)")
|
|
|
61 |
|
62 |
with col1:
|
63 |
st.header("Input")
|
64 |
+
target_url = st.text_input("Enter the target URL") # Define target_url here
|
65 |
|
66 |
+
generate_button = st.sidebar.button("Generate All")
|
67 |
+
reset_button = st.sidebar.button("Reset")
|
|
|
68 |
|
69 |
# Generate CSV and download button
|
70 |
+
if generate_button and target_url: # Check after target_url is defined
|
71 |
data = get_backlinks(api_login, api_key, target_url, filters)
|
72 |
if data:
|
73 |
df = pd.DataFrame(data)
|
|
|
76 |
href = f'<a href="data:file/csv;base64,{b64}" download="backlinks.csv">Download CSV file</a>'
|
77 |
st.markdown(href, unsafe_allow_html=True)
|
78 |
|
79 |
+
with col2:
|
80 |
+
st.header("Output")
|
81 |
+
# [Your code for displaying output]
|
82 |
+
|
83 |
# Reset functionality
|
84 |
if reset_button:
|
85 |
+
st.experimental_rerun()
|
|