报错显示:Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/div/div/div[1]/div[2]/div[2]/a"}(Session info: chrome=112.0.5615.87)
没有跳转弹出新的窗口
时间等待也有
选择的目标也是一个
报错显示:Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="__next"]/div/div/div[1]/div[2]/div[2]/a"}(Session info: chrome=112.0.5615.87)
没有跳转弹出新的窗口
时间等待也有
find_element最好是改成find_elements,不同用户访问生成的dom结构不一样,需要判断是否获取到,获取到再获取text属性。我这里显示的结构和题注就不一样
from selenium import webdriver
from selenium.webdriver.common.by import By
d=webdriver.Chrome()
d.get('https://www.bilibili.com/bangumi/play/ss44860')
aList=d.find_elements(By.CSS_SELECTOR,'.player-left-components>div[class^="mediainfo"]>div>a')
print(aList[0].text)
print(aList[1].text)
input()