This commit is contained in:
g1879 2020-12-04 22:32:06 +08:00
parent 95beaaa7e6
commit 3a0c7153db
2 changed files with 34 additions and 4 deletions

View File

@ -581,12 +581,28 @@ page.chrome_downloading() # Get the list of files that chrome is downloading
page.process_alert(mode, text) # Process the prompt box
```
### Use of cookies
MixPage supports obtaining and setting cookies. The specific usage methods are as follows:
```python
page.cookies # Return cookies in dictionary form, only cookies available for the current domain name will be returned
page.get_cookies(as_dict=False) # Return the cookies available for the current domain name in the form of a list, each cookie contains all the detailed information
page.get_cookies(all_domains=True) # Return all cookies in list form, only s mode is valid
page.set_cookies(cookies) # Set cookies, you can pass in RequestsCookieJar, list, tuple, str, dict
```
Tips:
- After setting cookies in d mode, you must refresh the page to see the effect.
- The s mode can set cookies in the ini file, SessionOptions, and configuration dictionary, which can be passed in when
MixPage is initialized. The d mode can only be set with the set_cookies() function.
## Find element
ele() returns the first eligible element, and eles() returns a list of all eligible elements.
You can use these two functions under the page object or element object to find subordinate elements.
ele() returns the first eligible element, and eles() returns a list of all eligible elements. You can use these two
functions under the page object or element object to find subordinate elements.
page.eles() and element.eles() search and return a list of all elements that meet the conditions.

View File

@ -585,14 +585,28 @@ page.chrome_downloading() # 获取 chrome 正在下载的文件列表
page.process_alert(mode, text) # 处理提示框
```
### cookies 的使用
MixPage 支持获取和设置 cookies具体使用方法如下
```python
page.cookies # 以字典形式返回 cookies只会返回当前域名可用的 cookies
page.get_cookies(as_dict=False) # 以列表形式返回当前域名可用 cookies每个 cookie 包含所有详细信息
page.get_cookies(all_domains=True) # 以列表形式返回所有 cookies只有 s 模式有效
page.set_cookies(cookies) # 设置 cookies可传入 RequestsCookieJar, list, tuple, str, dict
```
Tips:
- d 模式设置 cookies 后要刷新页面才能看到效果。
- s 模式可在 ini 文件、SessionOptions、配置字典中设置 cookies在 MixPage 初始化时即可传入d 模式只能用 set_cookies() 函数设置。
## 查找元素
ele() 返回第一个符合条件的元素eles() 返回所有符合条件的元素列表。
你可在页面对象或元素对象下使用这两个函数,以查找下级元素。
你可在页面对象或元素对象下使用这两个函数,以查找下级元素。
page.eles() 和 element.eles() 查找返回符合条件的所有元素列表。
page.eles() 和 element.eles() 查找返回符合条件的所有元素列表。
说明: