Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,69 @@
|
|
| 1 |
-
import
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
if __name__ == "__main__":
|
| 18 |
-
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template_string, request
|
| 2 |
+
import instaloader
|
| 3 |
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
L = instaloader.Instaloader()
|
| 6 |
+
|
| 7 |
+
# صفحة HTML بسيطة مع فورم لإدخال اليوزر
|
| 8 |
+
HTML_PAGE = """
|
| 9 |
+
<!DOCTYPE html>
|
| 10 |
+
<html lang="ar">
|
| 11 |
+
<head>
|
| 12 |
+
<meta charset="UTF-8">
|
| 13 |
+
<title>معلومات حساب إنستغرام</title>
|
| 14 |
+
<style>
|
| 15 |
+
body { font-family: Arial, sans-serif; background-color: #f0f0f0; padding: 20px; }
|
| 16 |
+
form { margin-bottom: 20px; }
|
| 17 |
+
input[type=text] { padding: 10px; width: 250px; }
|
| 18 |
+
input[type=submit] { padding: 10px 20px; }
|
| 19 |
+
.profile-info { background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1);}
|
| 20 |
+
img { border-radius: 50%; max-width: 150px; }
|
| 21 |
+
</style>
|
| 22 |
+
</head>
|
| 23 |
+
<body>
|
| 24 |
+
<h1>معلومات حساب إنستغرام</h1>
|
| 25 |
+
<form method="POST">
|
| 26 |
+
<input type="text" name="username" placeholder="أدخل اسم المستخدم" required>
|
| 27 |
+
<input type="submit" value="عرض المعلومات">
|
| 28 |
+
</form>
|
| 29 |
+
{% if profile %}
|
| 30 |
+
<div class="profile-info">
|
| 31 |
+
<h2>{{ profile.full_name }} ({{ profile.username }})</h2>
|
| 32 |
+
<p>عدد المتابعين: {{ profile.followers }}</p>
|
| 33 |
+
<p>عدد المتابعين له: {{ profile.followees }}</p>
|
| 34 |
+
<p>عدد المنشورات: {{ profile.mediacount }}</p>
|
| 35 |
+
<p>الوصف: {{ profile.biography }}</p>
|
| 36 |
+
<img src="{{ profile.profile_pic_url }}" alt="Profile Picture">
|
| 37 |
+
</div>
|
| 38 |
+
{% elif error %}
|
| 39 |
+
<p style="color:red;">{{ error }}</p>
|
| 40 |
+
{% endif %}
|
| 41 |
+
</body>
|
| 42 |
+
</html>
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
@app.route("/", methods=["GET", "POST"])
|
| 46 |
+
def index():
|
| 47 |
+
profile_data = None
|
| 48 |
+
error_msg = None
|
| 49 |
+
if request.method == "POST":
|
| 50 |
+
username = request.form.get("username")
|
| 51 |
+
try:
|
| 52 |
+
profile = instaloader.Profile.from_username(L.context, username)
|
| 53 |
+
profile_data = {
|
| 54 |
+
"full_name": profile.full_name,
|
| 55 |
+
"username": profile.username,
|
| 56 |
+
"followers": profile.followers,
|
| 57 |
+
"followees": profile.followees,
|
| 58 |
+
"biography": profile.biography,
|
| 59 |
+
"profile_pic_url": profile.profile_pic_url,
|
| 60 |
+
"mediacount": profile.mediacount
|
| 61 |
+
}
|
| 62 |
+
except Exception as e:
|
| 63 |
+
error_msg = f"حدث خطأ: {e}"
|
| 64 |
+
|
| 65 |
+
return render_template_string(HTML_PAGE, profile=profile_data, error=error_msg)
|
| 66 |
|
| 67 |
if __name__ == "__main__":
|
| 68 |
+
# عند تشغيل الكود، سيظهر الخادم على المتصفح
|
| 69 |
+
app.run(host="0.0.0.0", port=7860, debug=True, threaded=True)
|