From 1dfc61ddbb6654a1e5dc3238153ef408bf3126bc Mon Sep 17 00:00:00 2001
From: Irony <892768447@qq.com>
Date: Tue, 1 Oct 2019 21:39:27 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8B=A6=E6=88=AApost=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/PyQt.iml | 2 +-
.idea/misc.xml | 2 +-
QWebView/BlockRequest.py | 10 +++++++++-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/.idea/PyQt.iml b/.idea/PyQt.iml
index c8e73a1..e84e302 100644
--- a/.idea/PyQt.iml
+++ b/.idea/PyQt.iml
@@ -5,7 +5,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e454a58..3cb93a1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -56,5 +56,5 @@
-
+
\ No newline at end of file
diff --git a/QWebView/BlockRequest.py b/QWebView/BlockRequest.py
index a2edaa1..3db7d0d 100644
--- a/QWebView/BlockRequest.py
+++ b/QWebView/BlockRequest.py
@@ -9,7 +9,7 @@ Created on 2019年9月24日
@file: QWebView.BlockAds
@description: 拦截请求
"""
-from PyQt5.QtCore import QUrl
+from PyQt5.QtCore import QUrl, QBuffer, QByteArray
from PyQt5.QtNetwork import QNetworkAccessManager
from PyQt5.QtWebKitWidgets import QWebView
@@ -32,6 +32,14 @@ class RequestInterceptor(QNetworkAccessManager):
# 拦截百度联盟的广告
print('block:', url)
originalReq.setUrl(QUrl())
+ if op == self.PostOperation and outgoingData:
+ # 拦截或者修改post数据
+ # 读取后要重新设置,不然网站接收不到请求
+ data = outgoingData.readAll().data()
+ print('post data:', data)
+ # 修改data后重新设置
+ outgoingData = QBuffer(self)
+ outgoingData.setData(data)
return super(RequestInterceptor, self).createRequest(op, originalReq, outgoingData)