merhaba arkadaşlar kendim için tasarladıgım ve kodladıgım basit bu araci sizinle paylaşmak istedim bu araç instagram sorugulana kullanıcı adına iat bazi bilgileri çekiyor. be ekrana yazdiriyor
main.py: dosyası
from flask import Flask, render_template, request, send_file
import requests
from io import BytesIO
from urllib.parse import quote
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
user_data = None
if request.method == 'POST':
username = request.form.get('username')
headers = {
'user-agent': 'iphone',
'x-ig-app-id': '1217981644879628',
'x-requested-with': 'XMLHttpRequest',
}
response = requests.get(
'https://www.instagram.com/api/v1/users/web_profile_info/',
params={'username': username},
headers=headers,
)
if response.status_code == 200:
datam = response.json()
user_data = datam.get('data', {}).get('user', None)
if user_data:
print("Profile Picture URL:", user_data.get('profile_pic_url_hd')) # Debug line
return render_template('index.html', user_data=user_data)
@app.route('/proxy_image')
def proxy_image():
image_url = request.args.get('url')
encoded_url = quote(image_url, safe=':/?&=')
print("Fetching image from URL:", encoded_url) # Debugging line
try:
response = requests.get(encoded_url)
if response.status_code == 200:
content_type = response.headers.get('Content-Type')
print("Image Content-Type:", content_type) # Debugging line
return send_file(BytesIO(response.content), mimetype=content_type)
else:
print("Failed to fetch image. Status code:", response.status_code) # Debugging line
return "Image not found", 404
except requests.RequestException as e:
print(f"Error fetching image: {e}") # More informative error logging
return "Image could not be retrieved", 500
@app.route('/download_profile_pic')
def download_profile_pic():
image_url = request.args.get('url')
encoded_url = quote(image_url, safe=':/?&=')
try:
response = requests.get(encoded_url)
if response.status_code == 200:
return send_file(BytesIO(response.content), mimetype='image/jpeg', as_attachment=True, download_name='profile_pic.jpg')
else:
return "Image not found", 404
except requests.RequestException as e:
return "Image could not be retrieved", 500
if __name__ == '__main__':
app.run(debug=True)templates/index.html : dosyası
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instagram Profile Lookup</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2 class="text-center mb-4 heading">Instagram Profile Lookup</h2>
<form method="POST" action="/" class="text-center mb-5">
<input type="text" name="username" placeholder="Enter Instagram username" required class="form-control w-50 mx-auto input-field">
<button type="submit" class="btn custom-btn mt-3">Get Profile Info</button>
</form>
{% if user_data %}
<div class="card mx-auto profile-card" style="width: 20rem;">
<div class="text-center mt-3">
<img src="{{ url_for('proxy_image') }}?url={{ user_data.profile_pic_url_hd|urlencode }}" class="card-img-top profile-img" alt="{{ user_data.username }}'s Profile Picture">
</div>
<div class="card-body text-center">
<h5 class="card-title">{{ user_data.full_name }}</h5>
<p class="card-text">{{ user_data.biography }}</p>
</div>
<ul class="list-group list-group-flush text-center">
<li class="list-group-item"><strong>Username:</strong> {{ user_data.username }}</li>
<li class="list-group-item"><strong>User ID:</strong> {{ user_data.id }}</li>
<li class="list-group-item"><strong>Followers:</strong> {{ user_data.edge_followed_by.count }}</li>
<li class="list-group-item"><strong>Following:</strong> {{ user_data.edge_follow.count }}</li>
<li class="list-group-item"><strong>Private Account:</strong> {{ 'Yes' if user_data.is_private else 'No' }}</li>
<li class="list-group-item">
<strong>HD Profile Picture:</strong>
<a href="{{ user_data.profile_pic_url_hd }}" class="btn btn-primary mt-2" target="_blank" rel="noopener noreferrer">View/Download</a>
</li>
</ul>
</div>
{% endif %}
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>static/css/styles.css: dosyası
/* General Styling */
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
color: #333;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.heading {
color: #4b6584;
font-weight: 600;
}
/* Form Styles */
.input-field {
border-radius: 30px;
padding: 15px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-in-out;
}
.input-field:focus {
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
outline: none;
}
.custom-btn {
background-color: #4b6584;
color: white;
border-radius: 30px;
padding: 10px 30px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.custom-btn:hover {
background-color: #6c5ce7;
color: white;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
/* Profile Card */
.profile-card {
background-color: white;
border-radius: 15px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.profile-card:hover {
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.profile-img {
width: 100px;
height: 100px;
border-radius: 50%;
margin-top: -50px;
object-fit: cover;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.card-title {
font-weight: 600;
color: #2c3e50;
}
.card-text {
font-weight: 300;
color: #576574;
}
.list-group-item {
border: none;
background-color: transparent;
color: #576574;
}