我在使用selenium爬取的时候,对这种从标签名一样的标签中爬取信息时深感无力,求帮助
你可以先获取相同标签名的列表,再循环遍历找出需要的元素
li = driver.find_elements_by_xpath('........../li')
for v in li:
if v.text=="xxxxxx":
或者用filter()筛选也可以
根据节点位置,选择用nth-child或nth-last-child来选取,如图中要获取该节点,用driver.find_element_by_css_selector('ul.pagination li:nth-last-child(1)').text,就可获取">>"内容,然后用click()方法点击翻页。
如有帮助,点击我这个回答右上方的【采纳】按钮,谢谢。