try:
links = driver.find_elements_by_xpath('//div[@class="s-item__wrapper clearfix"]//a[@class="s-item__link"]')
for link in links:
print(link.get_attribute('href'))
I want to save all links file in txt file
try:
links = driver.find_elements_by_xpath('//div[@class="s-item__wrapper clearfix"]//a[@class="s-item__link"]')
for link in links:
print(link.get_attribute('href'))
I want to save all links file in txt file
with open('links.txt', 'w') as file:
try:
links = driver.find_elements_by_xpath('//div[@class="s-item__wrapper clearfix"]//a[@class="s-item__link"]')
file.write('\n'.join(links))
Use open()
to open files for read or write. More info here.