Update app.py
Browse files
app.py
CHANGED
@@ -42,20 +42,22 @@ def get_backlinks(api_login, api_key, target_url, filters):
|
|
42 |
# Debugging: Print out the keys of the response_data
|
43 |
st.text(f"Keys in response JSON: {list(response_data.keys())}")
|
44 |
|
45 |
-
if '
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
|
51 |
# Convert to DataFrame
|
52 |
-
df = pd.json_normalize(
|
53 |
return df
|
54 |
else:
|
55 |
-
st.error("Received empty '
|
56 |
return None
|
57 |
else:
|
58 |
-
st.error(f"No '
|
59 |
return None
|
60 |
else:
|
61 |
error_message = response.json().get('status_message', 'No specific error message provided')
|
|
|
42 |
# Debugging: Print out the keys of the response_data
|
43 |
st.text(f"Keys in response JSON: {list(response_data.keys())}")
|
44 |
|
45 |
+
if 'tasks' in response_data:
|
46 |
+
# Assuming there is only one task and one result within each task
|
47 |
+
task_result = response_data['tasks'][0]['result']
|
48 |
+
if task_result and 'items' in task_result[0]:
|
49 |
+
# The actual backlink items are nested within 'items'
|
50 |
+
items = task_result[0]['items']
|
51 |
+
st.text(f"First few items: {items[:5]}") # Debugging line to show the items structure
|
52 |
|
53 |
# Convert to DataFrame
|
54 |
+
df = pd.json_normalize(items)
|
55 |
return df
|
56 |
else:
|
57 |
+
st.error("Received empty 'result' from API or missing 'items'.")
|
58 |
return None
|
59 |
else:
|
60 |
+
st.error(f"No 'tasks' key in response JSON. Full response: {response_data}")
|
61 |
return None
|
62 |
else:
|
63 |
error_message = response.json().get('status_message', 'No specific error message provided')
|