Title

selenium执行js

### selenium执行js

```python
import json

import requests
from selenium import webdriver

from selenium.webdriver.common.by import By
import time

# selenium执行js
brower = webdriver.Chrome()
brower.get('https://www.pearvideo.com/')
brower.implicitly_wait(10)
brower.maximize_window()
brower.execute_script('alert(window.location)')#获取当前访问的地址
brower.execute_script('alert(document.cookie)')  # 获取当前登录的cookie
brower.execute_script('scrollTo(0,document.documentElement.scrollHeight)')#滑动到最后

time.sleep(10)
brower.close()
brower.quit()
posted @ 2023-07-11 18:08  哈哈哈哼  阅读(36)  评论(0编辑  收藏  举报