关于selenium爬取动态网站无法定位标签的问题
问题:
在使用selenium的find_element对input元素定位时(xpath),能够返回element对象,但是无法send_key,出现报错。报错内容:selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=119.0.6045.200)背景:
在爬取https://www.mintrust.com/informationDisclosure/netWorthDisclosure时,发现其为动态网页,决定无脑selenium时出现以上问题。
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get('https://www.mintrust.com/informationDisclosure/netWorthDisclosure')
b = driver.find_element(By.XPATH,'//*[@id="__layout"]/div/div[3]/div[1]/div[1]/div[1]/div/div[1]/div/input') #能够获取element对象
b.send_keys('海源') #无法send_key
- 自我排查:
借鉴网上经验,发现可能存在嵌套问题,但是如果是嵌套在定位时理应input元素也无法返回element元素。且搜索源代码也无对应标签。