2022-01-18 17:01:27 +08:00

27 lines
699 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

用 selenium 登录网站,然后切换到 requests 读取网页。两者会共享登录信息。
```python
from DrissionPage import MixPage
from time import sleep
# 创建页面对象,默认 d 模式
page = MixPage()
# 访问个人中心页面(未登录,重定向到登录页面)
page.get('https://gitee.com/profile')
# 使用 selenium 输入账号密码登录
page.ele('@id:user_login').input('your_user_name')
page.ele('@id:user_password').input('your_password\n')
sleep(1)
# 切换到 s 模式
page.change_mode()
# 登录后 session 模式的输出
print('登录后title', page.title, '\n')
```
输出:
```shell
登录后title 个人资料 - 码云 Gitee.com
```