您可以搜索ul
标记并循环搜索,然后获取元素的属性。
elements=driver.find_elements_by_css_selector("ul.plan-card-blue")
id_list=[]
for ele in elements:
id_list.append(ele.get_attribute("id"))
从浏览器中提取所有ul项
links = browser.find_elements_by_tag_name("ul")
循环列表并获取id值
for element in links
idValue = element.get_attribute("id")
想要将它保存在数组中使用它
idValue=[]
for element in links:
idValue.append(element.get_attribute("id"))