File size: 1,402 Bytes
b0d4b4c
2bef995
db68d10
b0d4b4c
 
 
2bef995
 
b0d4b4c
 
 
 
 
 
 
 
 
 
 
2bef995
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b0d4b4c
2bef995
 
b0d4b4c
 
b4cd4b3
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
from flask import Flask, render_template, request, jsonify
from curl_cffi import requests
import random

app = Flask(__name__)

# السيرفر المستقر (يمكنك تغييره من searx.space إذا لزم الأمر)
SEARXNG_URL = 'https://search.rhscz.eu'

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/search')
def search():
    query = request.args.get('q')
    if not query:
        return jsonify({"error": "No query provided"}), 400

    try:
        # 🚀 محاكاة كاملة لمتصفح Chrome 120 لتجاوز الحظر
        # impersonate="chrome120" تقوم بمحاكاة الـ TLS Fingerprint والـ Headers
        response = requests.get(
            f"{SEARXNG_URL}/search", 
            params={'q': query, 'format': 'json'},
            impersonate="chrome120", 
            timeout=10
        )
        
        if response.status_code == 200:
            return jsonify(response.json())
        elif response.status_code == 429:
            return jsonify({"error": "Server overloaded (429). Please try again in a minute."}), 429
        else:
            return jsonify({"error": f"Engine error: {response.status_code}"}), response.status_code
            
    except Exception as e:
        return jsonify({"error": f"Simulation Error: {str(e)}"}), 500

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860)