环境测试
from selenium import webdriver
chromedriver_path = r"C:\Program Files\Google\Chrome\Application\chromedriver.exe"
driver = webdriver.Chrome()
url = "https://www.xinpianchang.com/discover/article?from=navigator"
driver.get(url)
driver.close()
常用API
![](https://img-blog.csdnimg.cn/3068ac77eb764e4da9e4e9c0d06de0c6.png)
操作页面元素
![](https://img-blog.csdnimg.cn/d60e6086ddd44638b59b9d526e7c218b.png)
![](https://img-blog.csdnimg.cn/46abe862463f4dc681604876e327b285.png)
from selenium import webdriver
import json
chromedriver_path = r""
driver = webdriver.Chrome()
url = "https://passport.xinpianchang.com/login?redirect_uri=https%3A%2F%2Fwww.xinpianchang.com%2Fuser%2F14226548&mode=quick&type=phone"
driver.get(url)
with open(r"C:\Users\lenovo\Desktop\a.txt", 'r', encoding='utf-8') as rStream:
read = rStream.read()
replace = read.replace("'", '"').replace("True", "true").replace("False", "false").replace("Null", "null")
with open(r"", 'w', encoding='utf-8') as wStream:
write = wStream.write(replace)
with open(r"", 'r', encoding='utf-8') as rStream:
read = rStream.read()
import json
loads = json.loads(read)
print(loads)
for c in loads:
driver.add_cookie(c)
driver.get("https://www.xinpianchang.com/")