diff --git a/DrissionPage/config.py b/DrissionPage/config.py index db23e58..e5ba3d6 100644 --- a/DrissionPage/config.py +++ b/DrissionPage/config.py @@ -683,7 +683,7 @@ class DriverOptions(Options): self.binary_location = chrome_path if local_port is not None: - self.debugger_address = f'127.0.0.1:{local_port}' + self.debugger_address = '' if local_port == '' else f'127.0.0.1:{local_port}' if debugger_address is not None: self.debugger_address = debugger_address diff --git a/DrissionPage/mix_page.py b/DrissionPage/mix_page.py index 3cf80ef..c0a70b6 100644 --- a/DrissionPage/mix_page.py +++ b/DrissionPage/mix_page.py @@ -356,7 +356,7 @@ class MixPage(SessionPage, DriverPage, BasePage): def post(self, url: str, data: Union[dict, str] = None, - go_anyway: bool = False, + go_anyway: bool = True, show_errmsg: bool = False, retry: int = None, interval: float = None, diff --git a/docs/使用方法/访问网页.md b/docs/使用方法/访问网页.md index 46a832d..6d0bf8b 100644 --- a/docs/使用方法/访问网页.md +++ b/docs/使用方法/访问网页.md @@ -79,6 +79,24 @@ page.post('http://example.com', data=data) page.post('http://example.com', json=data) ``` +`data`参数和`json`参数都可接收`str`和`dict`格式数据,即有以下 4 种传递数据的方式: + +```python +# 向 data 参数传入字符串 +page.post(url, data='xxx') + +# 向 data 参数传入字典 +page.post(url, data={'xxx': 'xxx'}) + +# 向 json 参数传入字符串 +page.post(url, json='xxx') + +# 向 json 参数传入字典 +page.post(url, json={'xxx': 'xxx'}) +``` + + + # 其它请求方式 本库只针对常用的 get 和 post 方式作了优化,但也可以通过提取页面对象内的`Session`对象以原生 requests 代码方式执行其它请求方式。当然,它们工作在 s 模式。