只需10来行代码快速实现JSRpc,最简单的JSRPC
使用Flask和undetected-chromedriver快速实现JsRpc
推荐Python版本3.7.x及以上,需要pip安装
pip install Flask
pip install undetected-chromedriver
__author__ = 'jiuLiang'
__email__ = "jiuliange@foxmail.com"
import undetected_chromedriver as uc
from flask import Flask, request
app = Flask(__name__)
@app.route('/execute_js', methods=['POST', 'GET'])
def execute_js():
ex_js = request.args.get('ex_js') if request.method == "GET" else request.form.get('ex_js')
return str(driver.execute_script(f"return {ex_js};"))
if __name__ == '__main__':
driver = uc.Chrome()
driver.get('https://blog.csdn.net/qq_33613696')
app.run(host='127.0.0.1', port=8899)