joshuadunlop commited on
Commit
7a83db7
·
verified ·
1 Parent(s): 7e21d9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import streamlit as st
2
  import pandas as pd
3
  import requests
4
  from client import RestClient
@@ -6,9 +5,10 @@ import io
6
  import base64
7
  import requests
8
 
9
- def get_backlinks(api_key, target_url, filters):
 
10
  # Encoding credentials
11
- encoded_credentials = base64.b64encode(f"{api_key}:{api_key}".encode()).decode()
12
 
13
  # Setting headers with Basic Authentication
14
  headers = {
@@ -36,10 +36,16 @@ def get_backlinks(api_key, target_url, filters):
36
 
37
  # Streamlit layout
38
  st.sidebar.title("DataForSEO API Parameters")
 
39
  api_key = st.sidebar.text_input("API Key", type="password")
40
  generate_button = st.sidebar.button("Generate All")
41
  reset_button = st.sidebar.button("Reset")
42
 
 
 
 
 
 
43
  # Filters
44
  url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)")
45
  is_lost = st.sidebar.checkbox("Is Lost", value=False)
 
 
1
  import pandas as pd
2
  import requests
3
  from client import RestClient
 
5
  import base64
6
  import requests
7
 
8
+ # Function to call the DataForSEO API with Basic Authentication
9
+ def get_backlinks(api_login, api_key, target_url, filters):
10
  # Encoding credentials
11
+ encoded_credentials = base64.b64encode(f"{api_login}:{api_key}".encode()).decode()
12
 
13
  # Setting headers with Basic Authentication
14
  headers = {
 
36
 
37
  # Streamlit layout
38
  st.sidebar.title("DataForSEO API Parameters")
39
+ api_login = st.sidebar.text_input("API Login", value="[email protected]")
40
  api_key = st.sidebar.text_input("API Key", type="password")
41
  generate_button = st.sidebar.button("Generate All")
42
  reset_button = st.sidebar.button("Reset")
43
 
44
+ # Make sure to pass api_login to the get_backlinks function
45
+ if generate_button and target_url:
46
+ data = get_backlinks(api_login, api_key, target_url, filters)
47
+ # [Your existing code to handle the data and provide a download link for the CSV]
48
+
49
  # Filters
50
  url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)")
51
  is_lost = st.sidebar.checkbox("Is Lost", value=False)