Spaces:
Runtime error
Runtime error
File size: 2,053 Bytes
56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d 56ab695 bed830d | 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 | import gradio as gr
import requests
from bs4 import BeautifulSoup
def hunt_properties(location):
if not location:
return "⚠️ يرجى إدخال الوجهة أولاً."
search_url = (
f"https://html.duckduckgo.com/html/?q="
f"luxury+apartments+in+{location}+booking"
)
headers = {
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/120.0.0.0 Safari/537.36"
)
}
try:
response = requests.get(search_url, headers=headers, timeout=10)
soup = BeautifulSoup(response.text, "html.parser")
results = soup.find_all("a", class_="result__a")
if not results:
return f"❌ لم أجد نتائج مباشرة لـ {location}. حاول كتابة الاسم بالإنجليزية."
output = f"### 🦅 نتائج البحث في {location}:\n\n"
for i, res in enumerate(results[:8], 1):
title = res.get_text(strip=True)
link = res.get("href")
output += f"**{i}.** [{title}]({link})\n\n"
return output
except Exception as e:
return f"❌ خطأ تقني: {e}"
with gr.Blocks(theme=gr.themes.Soft(primary_hue="amber")) as demo:
gr.Markdown("# 🦅 B.com.ly Luxury Finder")
gr.Markdown("محرك بحث وسيط لتجاوز الحظر بطريقة آمنة.")
with gr.Row():
input_text = gr.Textbox(
label="أين تريد البحث؟",
placeholder="Sicily, London, Tripoli..."
)
search_btn = gr.Button("بدء الصيد 🎯", variant="primary")
output_md = gr.Markdown("بانتظار أوامرك يا قبطان...")
search_btn.click(
fn=hunt_properties,
inputs=input_text,
outputs=output_md
)
# 🔴 هذا السطر حاسم – أي خطأ فيه = التطبيق لا يعمل
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)
|