Spaces:
Runtime error
Runtime error
Fix Backlink Processing
#2
by notjulietxd - opened
- classes/Seo_Off_Page.py +15 -2
classes/Seo_Off_Page.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import requests
|
| 3 |
from dotenv import load_dotenv
|
|
@@ -102,8 +104,19 @@ class SeoOffPageAnalyst:
|
|
| 102 |
for file_info in st.session_state['uploaded_files'].values():
|
| 103 |
if file_info['type'] == 'pdf':
|
| 104 |
combined_text += file_info['content'] + "\n"
|
| 105 |
-
elif file_info['type'] == 'csv':
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# OUTPUT FOR SEO ANALYST
|
| 109 |
payload_txt = {"question": combined_text}
|
|
|
|
| 1 |
+
from io import StringIO
|
| 2 |
+
from urllib.parse import urlparse
|
| 3 |
import streamlit as st
|
| 4 |
import requests
|
| 5 |
from dotenv import load_dotenv
|
|
|
|
| 104 |
for file_info in st.session_state['uploaded_files'].values():
|
| 105 |
if file_info['type'] == 'pdf':
|
| 106 |
combined_text += file_info['content'] + "\n"
|
| 107 |
+
elif file_info['type'] == 'csv':
|
| 108 |
+
# Load CSV
|
| 109 |
+
df = pd.read_csv(StringIO(file_info['content'].to_csv(index=True)))
|
| 110 |
+
|
| 111 |
+
# Count total rows
|
| 112 |
+
num_rows = len(df)
|
| 113 |
+
|
| 114 |
+
# Extract unique domains from 'Source url'
|
| 115 |
+
df['Source Domain'] = df['Source url'].apply(lambda x: urlparse(x).netloc)
|
| 116 |
+
unique_domains = df['Source Domain'].nunique()
|
| 117 |
+
|
| 118 |
+
combined_text += f"Total rows: {num_rows}\n"
|
| 119 |
+
combined_text += f"Referring Domain: {unique_domains}"
|
| 120 |
|
| 121 |
# OUTPUT FOR SEO ANALYST
|
| 122 |
payload_txt = {"question": combined_text}
|