0% found this document useful (0 votes)
4 views

API

This document is a Python Flask application that checks the availability of an email address by sending requests to a specified URL. It uses BeautifulSoup for HTML parsing and handles CSRF tokens and session cookies for secure requests. The application includes error handling and returns responses in JSON format, supporting Arabic language output.

Uploaded by

mmmeedddimuameed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

API

This document is a Python Flask application that checks the availability of an email address by sending requests to a specified URL. It uses BeautifulSoup for HTML parsing and handles CSRF tokens and session cookies for secure requests. The application includes error handling and returns responses in JSON format, supporting Arabic language output.

Uploaded by

mmmeedddimuameed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

from flask import Flask, request, Response

from bs4 import BeautifulSoup


import requests
import json

app = Flask(__name__)

u = {}
b = "https://3bili.com"
h = {
'User-Agent': "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36",
'Accept':
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/
webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'cache-control': "max-age=0",
'sec-ch-ua': "\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\"",
'sec-ch-ua-mobile': "?1",
'sec-ch-ua-platform': "\"Android\"",
'upgrade-insecure-requests': "1",
'sec-fetch-site': "none",
'sec-fetch-mode': "navigate",
'sec-fetch-user': "?1",
'sec-fetch-dest': "document",
'accept-language': "ar-EG,ar;q=0.9,en-US;q=0.8,en;q=0.7",
}

def ft():
r = requests.get(b, headers=h)
r.raise_for_status()
s = BeautifulSoup(r.text, 'html.parser')
cs = s.find('input', {'id': 'csrf_token'})['value']
tk = r.cookies.get('PHPSESSID')
return cs, tk

@app.route('/')
def hm():
return "‫شغال‬."

@app.route('/check', methods=['GET'])
def ck():
em = request.args.get("email")
if not em:
return Response(
response=json.dumps({"error": " ‫من فضلك أدخل البريد الإلكتروني في‬
‫الرابط‬."}, ensure_ascii=False),
content_type="application/json; charset=utf-8",
status=400
)

uid = request.remote_addr
cs, tk = ft()

try:
while True:
purl = f"{b}/answer.php"
prm = {'version': "0.7517866631793415"}
data = {
'csrf_token': cs,
'operator_service': "syriatel",
'typed': "0",
'sender_num': "9647723708853",
'sender_email': em,
'receiver_num': "9673348686",
'us_amount': "2.00",
'sy_amount': "13039",
'coupon': ""
}
hd = {
**h,
'x-requested-with': "XMLHttpRequest",
'origin': b,
'sec-fetch-site': "same-origin",
'sec-fetch-mode': "cors",
'sec-fetch-dest': "empty",
'referer': b,
'Cookie': f"PHPSESSID={tk}"
}
res = requests.post(purl, params=prm, data=data, headers=hd)
res.raise_for_status()

u[uid] = u.get(uid, 0) + 1

if u[uid] > 100:


cs, tk = ft()
u[uid] = 0
continue

st = "‫ "الإيميل غير متاح‬if "‫ "الإيميل المدخل صحيح ولكنه غير موجود‬in
res.text else "‫"الإيميل متاح‬
out = {"email": em, "status": f"{st} [↯] @Q_B_H"}

return Response(
response=json.dumps(out, ensure_ascii=False),
content_type="application/json; charset=utf-8",
status=200
)
except Exception as e:
return Response(
response=json.dumps({"error": f"‫حدث خطأ‬: {str(e)}"},
ensure_ascii=False),
content_type="application/json; charset=utf-8",
status=500
)

@app.errorhandler(404)
def nf(e):
return "‫خطا بال‬api 404 ,"‫مالتك‬

if __name__ == '__main__':
app.run(debug=False, use_reloader=False)

You might also like