mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.0.30增加set_headers()、m_click();动作链增加功能
This commit is contained in:
parent
126dade689
commit
8e96d492fb
@ -126,6 +126,8 @@ class ChromiumBase(BasePage):
|
||||
|
||||
def set_cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None: ...
|
||||
|
||||
def set_headers(self, headers: dict) -> None: ...
|
||||
|
||||
def ele(self,
|
||||
loc_or_ele: Union[Tuple[str, str], str, ChromiumElement, ChromiumFrame],
|
||||
timeout: float = ...) -> Union[ChromiumElement, ChromiumFrame, None]: ...
|
||||
|
@ -305,15 +305,15 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
if set_session:
|
||||
super().set_cookies(cookies)
|
||||
|
||||
# def set_headers(self, headers: dict) -> None:
|
||||
# """设置固定发送的headers \n
|
||||
# :param headers: dict格式的headers数据
|
||||
# :return: None
|
||||
# """
|
||||
# if self._mode == 's':
|
||||
# self.session.headers = headers
|
||||
# elif self._mode == 'd':
|
||||
# super(SessionPage, self).set_headers(headers)
|
||||
def set_headers(self, headers: dict) -> None:
|
||||
"""设置固定发送的headers \n
|
||||
:param headers: dict格式的headers数据
|
||||
:return: None
|
||||
"""
|
||||
if self._has_session:
|
||||
return super().set_headers(headers)
|
||||
if self._has_driver:
|
||||
super(SessionPage, self).set_headers(headers)
|
||||
|
||||
def check_page(self, by_requests=False):
|
||||
"""d模式时检查网页是否符合预期 \n
|
||||
|
@ -345,6 +345,21 @@ page.set_page_load_strategy.eager()
|
||||
|
||||
**返回:**`None`
|
||||
|
||||
## 📍 `set_headers()`
|
||||
|
||||
此方法用于设置headers参数,两种模式都支持。s 模式下,新 headers 值会逐项覆盖原来的,不会删除原来未被设置的值。
|
||||
|
||||
**参数:**
|
||||
|
||||
- `headers`:`dict`形式的 headers
|
||||
|
||||
**返回:**`None`
|
||||
|
||||
```python
|
||||
h = {'connection': 'keep-alive', 'accept-charset': 'GB2312,utf-8;q=0.7,*;q=0.7'}
|
||||
page.set_headers(headers=h)
|
||||
```
|
||||
|
||||
# ✔️ 窗口管理
|
||||
|
||||
## 📍 调整大小和位置
|
||||
|
@ -56,11 +56,11 @@
|
||||
|
||||
* [⚡️ 7 示例和技巧](#)
|
||||
|
||||
* [🌠 自动登录码云](实用示例\自动登录码云.md)
|
||||
* [🌠 采集猫眼电影TOP100榜](实用示例\采集猫眼电影TOP100榜.md)
|
||||
* [🌠 下载星巴克产品图片](实用示例\下载星巴克产品图片.md)
|
||||
* [🌠 下载豆瓣图书封面图片](实用示例\下载豆瓣图书封面图片.md)
|
||||
* [🌠 多线程操作多标签页](实用示例\多线程操作多标签页.md)
|
||||
* [🌠 自动登录码云](示例和技巧\自动登录码云.md)
|
||||
* [🌠 采集猫眼电影TOP100榜](示例和技巧\采集猫眼电影TOP100榜.md)
|
||||
* [🌠 下载星巴克产品图片](示例和技巧\下载星巴克产品图片.md)
|
||||
* [🌠 下载豆瓣图书封面图片](示例和技巧\下载豆瓣图书封面图片.md)
|
||||
* [🌠 多线程操作多标签页](示例和技巧\多线程操作多标签页.md)
|
||||
|
||||
* [🔖 9 版本历史](版本历史.md)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user