Flask 框架写的一个抖音快手去水印平台(正在完善)

templates  视图层

static     css js

from flask import Flask, render_template, request
import requests
import re
import datetime
import random
from flask import Flask, session, redirect, url_for, escape, request

app = Flask(__name__)

app.secret_key = 'fkdjsafjdkfdlkjfadskjfadskljdsfklj'


# 主目录
@app.route('/')
def index():
    if 'username' in session and 'pass' in session:
        username = session['username']
        url='https://s.weibo.com/top/summary'
        headers = {
         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.57'
            }
        response = requests.get(url,headers=headers).text
        biaoti= re.findall(r'_blank">(.+?)</a>', response)  # 正则表达式匹配
        print(biaoti)
        wb_1,wb_2,wb_3,wb_4,wb_5,wb_6,wb_7,wb_8,wb_9,wb_10=biaoti[0],biaoti[1],biaoti[2],biaoti[3],biaoti[4],biaoti[5],biaoti[6],biaoti[7],biaoti[8],biaoti[9]

        return render_template('index.html', username=username,wb_1=wb_1,wb_2=wb_2,wb_3=wb_3,wb_4=wb_4,wb_5=wb_5,wb_6=wb_6,wb_7=wb_7,wb_8=wb_8,wb_9=wb_9,wb_10=wb_10 )

    return render_template('lyear_pages_login_3.html')



##########################################################################
# 功能实现模块
# 抖音解析
@app.route('/result', methods=['POST', 'GET'])
def result():
    if request.method == 'POST':
        try:
            result = request.form['URL']
            headers = {
                'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Mobile Safari/537.36 Edg/87.0.664.47'}
            # 这里chrome的user-agent获取方式:在浏览器地址栏输入 about://version 即可得到结果
            print(result)
            url = result
            na = re.findall(r"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)",
                            url)  # 正则表达式匹配
            a = na[0]
            url_a = a[0]
            # 请求网页
            response = requests.get(url_a)
            # print(response.status_code)  # 打印响应的状态码
            url_2 = response.url  # 打印重定向后的网址
            n = re.findall(r"video/(.+?)/", url_2)  # 正则表达式匹配
            id = n[0]
            url_3 = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' + id
            # print(url_3)
            josn_1 = requests.get(url_3)
            conten = josn_1.text
            n2 = re.findall(r'playwm/?(.+?)"', conten)  # 正则表达式匹配
            shuiyin = 'https://aweme.snssdk.com/aweme/v1/play/' + n2[0]
            print(shuiyin)
            aa = requests.get(shuiyin, headers=headers)
            zhu = aa.url
            print(zhu)

            return render_template("result.html",zhu=zhu)
        except:
            return render_template("douyinerror.html")
    else:
        return render_template("error.html")



# 快手解析
@app.route('/ks2', methods=['POST', 'GET'])
def ks():
    if request.method == 'POST':
        try:
            result = request.form['URL']
            na = result
            na_1 = re.findall(
                r"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)",
                na)  # 正则表达式匹配
            na_2 = na_1[0]
            url = na_2[0]
            # print(url)
            headers = {
                'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'}
            # 这里chrome的user-agent获取方式:在浏览器地址栏输入 about://version 即可得到结果
            # 请求网页
            response = requests.get(url, headers=headers)
            redirect_url = response.url  # 打印重定向后的网址
            # print(redirect_url)
            code = requests.get(url=redirect_url, headers=headers).text
            # print(code)
            n2 = re.findall(r'src="(.+?).mp4?', code)  # 正则表达式匹配
            final_url = n2[0] + '.mp4'
            print(final_url)

            return render_template("ks2.html", final_url=final_url)
        except:
            return render_template("error.html")
    else:
        return render_template("error.html")

# 图片
@app.route('/lyear_pages_gallery', methods=['POST', 'GET'])
def img():
    if 'username' in session and 'pass' in session:
        a = requests.get(
            'https://api.bbs.lieyou888.com/post/list/ANDROID/1.1?start='
            '1607339238000&count=20&versioncode=75&cat_id=106&sort_by=0&market_id=c'
            'loudgame_wandoujia&platform=2&app_version=1.1.67&tag_id=10601&device_code=%5Ba%5D5d8d2c0ac683d2ab')
        conten = a.json()
        aa = conten['posts']
        # print(aa)
        i = 0
        list = []
        for name in aa:
            # print(name['title'])
            img = name['images']
            for name2 in img:
                i += 1
                # print(i)
                # print(name2)
                list.append(name2)
        num,num1,num2,num4,num5,num6,num7,num8,num9,num10,num11,num12,num13,num14,num15,num16,num17,num18,num19,num20=random.randint(0,5),  random.randint(5,10),  random.randint(10,15),  random.randint(15,20),  random.randint(20,25),random.randint(25, 30), random.randint(30, 35), random.randint(35, 40), random.randint(40, 45), random.randint(45,50),random.randint(50, 55), random.randint(55, 60), random.randint(60, 65), random.randint(65, 70), random.randint(70,75),random.randint(75, 80), random.randint(80, 85), random.randint(85, 90), random.randint(90, 95), random.randint(95,100)
        img,img_1,img_2,img_3,img_4,img_5,img_6,img_7,img_8,img_9,img_10,img_11,img_12,img_13,img_14,img_15,img_16,img_17,img_18,img_19=list[num],list[num1],list[num2],list[num4],list[num5],list[num6],list[num7],list[num8],list[num9],list[num10],list[num11],list[num12],list[num13],list[num14],list[num15],list[num16],list[num17],list[num18],list[num19],list[num20]
        return render_template('lyear_pages_gallery.html',
                               img_1=img_1,
                               img_2=img_2,
                               img_3=img_3,
                               img_4=img_4,
                               img_5=img_5,
                               img_6=img_6,
                               img_7=img_7,
                               img_8=img_8,
                               img_9=img_9,
                               img_10=img_10,
                               img_11=img_11,
                               img_12=img_12,
                               img_13=img_13,
                               img_14=img_14,
                               img_15=img_15,
                               img_16=img_16,
                               img_17=img_17,
                               img_18=img_18,
                               img_19=img_19,
                               img=img



                               )


##########################################################################

# 视图层
@app.route('/lyear_ui_cards')
def lyear_ui_cards():
    if 'username' in session and 'pass' in session:
        return render_template("lyear_ui_cards.html")

@app.route('/ks')
def ks_():
    if 'username' in session and 'pass' in session:
        return render_template("ks.html")
@app.route('/lyear_pages_gallery')
def img_():
    # if 'username' in session and 'pass' in session:
        return render_template("lyear_pages_gallery.html")
##########################################################################    
@app.route('/login', methods=['GET', 'POST'])
# 登录
def login():
    session.permanent = True
    app.permanent_session_lifetime = datetime.timedelta(minutes=60)  # 设置session到期时间
    if request.method == 'POST':

        session['username'] = request.form['username']
        session['pass'] = request.form['pass']
        session.permanent = True
        user = request.form['username']
        pwd = request.form['pass']
        print(pwd)
        if user == 'admin' and pwd == '123456':

            return redirect(url_for('index'))
        else:
            error = '对不起,账号或密码错误,请重新输入'
            return render_template('lyear_pages_login_3.html', error=error)

    return render_template('lyear_pages_login_3.html')

@app.route('/logout')
# 退出
def logout():
    # remove the username from the session if it is there

    session.pop('username', None)

    return redirect(url_for('index'))

####################################################################
if __name__ == '__main__':
    app.run(debug=True)

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容