joshuadunlop commited on
Commit
d0479df
·
verified ·
1 Parent(s): 486fe7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -12,23 +12,19 @@ def get_backlinks(api_login, api_key, target_url, filters):
12
  'Authorization': f'Basic {encoded_credentials}'
13
  }
14
 
15
- # Prepare post data
16
  post_data = {
17
  0: {
18
  "target": target_url,
19
  "limit": 1000,
20
  "mode": "as_is",
21
- "filters": [f"{filter[0]}:{filter[1]}:{filter[2]}" for filter in filters] if filters else []
22
  }
23
  }
24
 
25
  # Making the API request
26
  response = requests.post("https://api.dataforseo.com/v3/backlinks/backlinks/live", json=post_data, headers=headers)
27
 
28
- # Log the full response for debugging
29
- st.text("API Response:")
30
- st.json(response.json()) # This will display the full JSON response in the Streamlit app
31
-
32
  # Check if the response contains 'results' key
33
  if response.status_code == 200 and 'results' in response.json():
34
  # Extract the results
@@ -45,7 +41,7 @@ def get_backlinks(api_login, api_key, target_url, filters):
45
  error_message = response.json().get('status_message', 'No specific error message provided')
46
  st.error(f"Error: Code: {response.status_code} Message: {error_message}")
47
  return None
48
-
49
  # Streamlit layout
50
  st.sidebar.title("DataForSEO API Parameters")
51
  api_login = st.sidebar.text_input("API Login", value="[email protected]")
 
12
  'Authorization': f'Basic {encoded_credentials}'
13
  }
14
 
15
+ # Prepare post data with filters as a list of lists
16
  post_data = {
17
  0: {
18
  "target": target_url,
19
  "limit": 1000,
20
  "mode": "as_is",
21
+ "filters": filters
22
  }
23
  }
24
 
25
  # Making the API request
26
  response = requests.post("https://api.dataforseo.com/v3/backlinks/backlinks/live", json=post_data, headers=headers)
27
 
 
 
 
 
28
  # Check if the response contains 'results' key
29
  if response.status_code == 200 and 'results' in response.json():
30
  # Extract the results
 
41
  error_message = response.json().get('status_message', 'No specific error message provided')
42
  st.error(f"Error: Code: {response.status_code} Message: {error_message}")
43
  return None
44
+
45
  # Streamlit layout
46
  st.sidebar.title("DataForSEO API Parameters")
47
  api_login = st.sidebar.text_input("API Login", value="[email protected]")