diff --git a/app.py b/app.py new file mode 100644 index 0000000000000000000000000000000000000000..252016c0c1c8caf7bd7fa9f2a5b6cef6d9baa6a0 --- /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 90ffb6fd9269e3f15d7c7fde03a72b5c8b66da54..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..f9bc32c34b275cb2cc08bdff349fab7e137cb27f --- /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 0000000000000000000000000000000000000000..d5fa9de30b6af9ca9822d54de29e02241ea95d6f --- /dev/null +++ b/templates/index.html @@ -0,0 +1,11 @@ + + + + + dr_py首页 + + +

欢迎使用dr_py项目

+

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

+ + \ No newline at end of file