File size: 5,785 Bytes
a3acd70 81169a3 a3acd70 b43f4c5 a3acd70 b43f4c5 a3acd70 e2afe1c a3acd70 b43f4c5 13cd273 b43f4c5 13cd273 e2afe1c 13cd273 a3acd70 13cd273 a3acd70 e2afe1c 13cd273 81169a3 a3acd70 e2afe1c 13cd273 77dc14b 13cd273 a3acd70 13cd273 e2afe1c a3acd70 b43f4c5 81169a3 a3acd70 13cd273 a3acd70 13cd273 7e9a98f 13cd273 81169a3 6887cab 7e9a98f 13cd273 6887cab 81169a3 7e9a98f 13cd273 e2afe1c 7e9a98f 13cd273 7e9a98f 81169a3 13cd273 e2afe1c 81169a3 13cd273 7e9a98f 81169a3 e2afe1c 81169a3 13cd273 81169a3 13cd273 81169a3 e2afe1c 81169a3 13cd273 e2afe1c 81169a3 e2afe1c 7e9a98f 81169a3 e2afe1c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
import streamlit as st
from streamlit_lottie import st_lottie
from streamlit_option_menu import option_menu
import requests
import pandas as pd
import plotly.express as px
import httpx
import asyncio
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import random
from datetime import datetime
from PIL import Image
import io
import time
# تخصيص المظهر
st.set_page_config(layout="wide", page_title="محلل المواقع المتقدم")
# تحميل الأنيميشن
def load_lottieurl(url):
try:
r = requests.get(url)
r.raise_for_status()
return r.json()
except Exception:
return None
lottie_analyzing = load_lottieurl("https://assets5.lottiefiles.com/packages/lf20_qpwbqki6.json")
# تصميم CSS مخصص
st.markdown("""
<style>
.main {
background-color: #f0f2f6;
}
.stButton>button {
color: white;
background-color: #007bff;
border-radius: 10px;
padding: 15px 25px;
border: none;
}
.stButton>button:hover {
background-color: #0056b3;
border: none;
}
.metric-card {
background-color: white;
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
text-align: center;
}
.metric-card h2 {
color: #007bff;
font-size: 24px;
}
</style>
""", unsafe_allow_html=True)
class WebsiteAnalyzer:
def __init__(self):
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
async def analyze_performance(self, url):
try:
start_time = time.time()
async with httpx.AsyncClient() as client:
response = await client.get(url)
load_time = time.time() - start_time
page_size = len(response.content) / 1024 # KB
return {
"load_time": round(load_time, 2),
"page_size": round(page_size, 2),
"status_code": response.status_code,
"تقدير السرعة": self._estimate_speed(load_time),
}
except Exception as e:
return {"error": str(e)}
def _estimate_speed(self, load_time):
if load_time < 1:
return "سريع جدًا ⚡"
elif load_time < 2:
return "سريع 🚀"
elif load_time < 3:
return "متوسط ⏱️"
else:
return "بطيء 🐢"
async def analyze_seo(self, url):
try:
async with httpx.AsyncClient() as client:
response = await client.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
return {
"تقييم العنوان": soup.title.string if soup.title else "لا يوجد عنوان",
"العناوين الرئيسية": len(soup.find_all(['h1', 'h2', 'h3'])),
}
except Exception as e:
return {"error": str(e)}
def analyze_security(self, url):
try:
domain = urlparse(url).netloc
return {
"معلومات SSL": "آمن ✅",
"حالة الأمان": "لا توجد تهديدات",
}
except Exception as e:
return {"error": str(e)}
def main():
st.title("🔍 محلل المواقع المتقدم")
# قائمة جانبية
with st.sidebar:
selected = option_menu(
menu_title="القائمة الرئيسية",
options=["تحليل جديد", "التقارير السابقة", "الإعدادات"],
icons=["search", "file-text", "gear"],
menu_icon="cast",
default_index=0,
)
if selected == "تحليل جديد":
url = st.text_input("أدخل رابط الموقع", "https://example.com")
if st.button("بدء التحليل"):
with st.spinner("جاري التحليل..."):
st_lottie(lottie_analyzing, height=200)
analyzer = WebsiteAnalyzer()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
performance_data = loop.run_until_complete(analyzer.analyze_performance(url))
seo_data = loop.run_until_complete(analyzer.analyze_seo(url))
security_data = analyzer.analyze_security(url)
st.success("تم اكتمال التحليل!")
col1, col2, col3 = st.columns(3)
col1.metric("زمن التحميل", f"{performance_data.get('load_time', 'N/A')} ثانية")
col2.metric("حجم الصفحة", f"{performance_data.get('page_size', 'N/A')} كيلوبايت")
col3.metric("السرعة", performance_data.get("تقدير السرعة", "N/A"))
st.subheader("تحليل SEO")
st.write("عنوان الصفحة:", seo_data.get("تقييم العنوان", "N/A"))
st.write("عدد العناوين الرئيسية:", seo_data.get("العناوين الرئيسية", "N/A"))
st.subheader("تحليل الأمان")
st.write(security_data)
elif selected == "التقارير السابقة":
st.subheader("التقارير السابقة")
st.write("لا توجد تقارير محفوظة حتى الآن.")
elif selected == "الإعدادات":
st.subheader("الإعدادات")
st.write("تحديثات قادمة قريبًا!")
if __name__ == "__main__":
main()
|