#如何在以下代码中添加点击next按钮获取每一页链接,直到无法点击next或页面结束,将输出的所有链接保存到我的a[]中
```python
a = {}
for links in driver.find_elements(By.XPATH,
'//*[@class="a-link-normal s-underline-text s-underline-link-text s-link-style '
'a-text-normal"]'):
sleep(1)
print(links.get_attribute('href'))
# a.append(links.get_attribute('href'))
# 等待10秒直到元素完善
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.s-search-results")))
# 获取搜索结果的链接
links = driver.find_elements(By.CSS_SELECTOR, 'a.a-link-normal.s-no-outline')
url_list = [link.get_attribute('href') for link in links]
for url in url_list:
driver.get(url)
try:
# 等待页面加载完成
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "productTitle")))
# 获取数据链接
seller_link = driver.find_element(By.ID, "sellerProfileTriggerId").get_attribute('href')
#点击滑动元素
driver.execute_script("arguments[0].scrollIntoView();", driver.find_element(By.ID, "sellerProfileTriggerId"))
driver.refresh()
sleep(3)
driver.find_element(By.ID, "sellerProfileTriggerId").click()
seller_box = driver.find_element(By.CSS_SELECTOR,
'#page-section-detail-seller-info > div:nth-child(1) > div:nth-child(1)').text
except NoSuchElementException:
continue
# 输出链接
print(seller_link)
# 输出要获取的内容
print(seller_box)
#点击下一页元素为linkText=Next
```