环境测试
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
操作页面元素
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/")