From a9e011a0f9120802e38da6a9c88d3e2f2f1a3d8e Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 25 Aug 2022 09:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 32 ++++++++++++++++++++++++++++++++ main.py | 16 ---------------- requirements.txt | 4 ++++ templates/index.html | 11 +++++++++++ 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 app.py delete mode 100644 main.py create mode 100644 requirements.txt create mode 100644 templates/index.html diff --git a/app.py b/app.py new file mode 100644 index 0000000..252016c --- /dev/null +++ b/app.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : app.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/8/25 + +from flask import Flask, jsonify, abort,request,redirect,make_response,render_template + +import sys +import codecs +sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) + +app = Flask(__name__) +app.config["JSON_AS_ASCII"] = False # jsonify返回的中文正常显示 +MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36' +PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36' +UA = 'Mozilla/5.0' +headers = { + 'Referer': 'https://www.baidu.com', + 'user-agent': UA, +} + +@app.route('/') +def forbidden(): # put application's code here + abort(403) + +@app.route('/index') +def index(): # put application's code here + return render_template('index.html') + +if __name__ == '__main__': + app.run(host="0.0.0.0", port=9000) \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 90ffb6f..0000000 --- a/main.py +++ /dev/null @@ -1,16 +0,0 @@ -# 这是一个示例 Python 脚本。 - -# 按 Shift+F10 执行或将其替换为您的代码。 -# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。 - - -def print_hi(name): - # 在下面的代码行中使用断点来调试脚本。 - print(f'Hi, {name}') # 按 Ctrl+F8 切换断点。 - - -# 按间距中的绿色按钮以运行脚本。 -if __name__ == '__main__': - print_hi('PyCharm') - -# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f9bc32c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +PyExecJS +pyquery +flask +requests \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..d5fa9de --- /dev/null +++ b/templates/index.html @@ -0,0 +1,11 @@ + + + + + dr_py首页 + + +

欢迎使用dr_py项目

+

可以简单的自定义爬虫实现cms数据接口

+ + \ No newline at end of file -- GitLab