我试图获取 Google Trends 中一个元素的 xpath,该元素似乎是动态的,导致控制台中出现奇怪的重新加载,这不允许我获取路径。因此,我也尝试通过我看到的 id 进行选择,但仍然无法正常工作。
我想做的是在搜索框中添加一个标题为“添加搜索词”的比较查询(在第一次单击同一元素后)。
这是一个示例网址:https ://trends.google.com/trends/explore?q=python%20programming&geo=US
也许我需要等待?当我尝试在控制台中检查时,我对隐藏的 html 感到困惑。
# click to add and compare query
driver.find_element_by_xpath('//*[@id="explorepage-content-header"]/explore-pills/div/button/span/span[1]').click()
time.sleep(10)
# find comparisson search box
driver.maximize_window()
driver.implicitly_wait(20)
ele = driver.find_element_by_id('input-139')
time.sleep(1)
ele.send_keys('r programming') <-- im not able to add this query in the comparison box
ele.send_keys(Keys.RETURN)
这是错误信息。
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="input-139"]"}
(Session info: chrome=81.0.4044.138)
慕桂英3389331
慕雪6442864
相关分类