我目前正在寻找创建一个Python脚本,该脚本查看传入的HTTP或HTTPS流量并对其进行更改。这需要是100%自动的。这将在我的本地计算机上运行。 我需要这样的东西:
def Change(request):
#Get all incoming HTTPS and HTTP traffic
#Change the request
while true:
#Get all incoming HTTPS and HTTP traffic
Change(request)
这显然要复杂得多。用户连接到页面时,我需要更改网站html。例如,从此更改传入的html文件:
<form action="/example.php">
First name:<br>
<input type="text" name="firstname" value="Bob"><br>
Last name:<br>
<input type="text" name="lastname" value="Mc Bob"><br><br>
<input type="submit" value="Submit">
</form>
收件人
<title>Hey</title>
<form action="/example.php">
First name:<br>
<input type="text" name="firstname" value="Bob"><br>
Last name:<br>
<input type="text" name="lastname" value="Mc Bob"><br><br>
<input type="submit" value="Submit">
</form>
非常感谢,如果我把代码弄乱了,我仍然在学习。
答案 0 :(得分:0)
您是否正在寻找类似的东西?
from functools import wraps
def request_decorator(view_func):
def _decorator(request, *args, **kwargs):
# do something with request before the view_func call
response = view_func(request, *args, **kwargs)
return response
return wraps(view_func)(_decorator)
# Use it like this
@request_decorator
def foo(request):
return HttpResponse('...')