-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflaskv2.py
70 lines (51 loc) · 2.3 KB
/
flaskv2.py
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
69
70
from flask import Flask, request, jsonify
import requests
from bs4 import BeautifulSoup
import re
app = Flask(__name__)
@app.route('/url=<path:url>', methods=['GET'])
def get_download_link(url):
# Check if the URL contains "mlwbd"
if "mlwbd" not in url:
return jsonify({"error": "Go away Demon! Use only MLWBD link."})
# first req
response1 = requests.get(url)
if response1.status_code == 200:
# init soup
soup1 = BeautifulSoup(response1.text, 'html.parser')
# get FU
fu_value = soup1.find('input', {'name': 'FU'}).get('value')
# Second request
second_url = "https://freethemesy.com/career-guide-software-development-for-your-bright-future"
payload = {
"FU4": fu_value
}
headers = {
"authority": "freethemesy.com",
"content-type": "application/x-www-form-urlencoded",
"origin": "https://freethemesy.com",
"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"
}
response2 = requests.post(second_url, data=payload, headers=headers)
match = re.search(r'window\.location\.href\s*=\s*"([^"]+)"', response2.text)
if match:
href_value = match.group(1)
third_url = "https://namemeaningbengali.com/new/l/api/m"
third_payload = {
"s": href_value
}
third_headers = {
"authority": "namemeaningbengali.com",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"origin": "https://namemeaningbengali.com",
"x-requested-with": "XMLHttpRequest"
}
third_response = requests.post(third_url, data=third_payload, headers=third_headers)
download_link = third_response.text
return jsonify({"Download Link": download_link})
else:
return jsonify({"error": "Download Link token is not found"})
else:
return jsonify({"error": f"Check your url, demon. Status code: {response1.status_code}"})
if __name__ == '__main__':
app.run(debug=True)