I am trying to extract all the links from wikipedia homepage but this code showing TypeError: 'WebElement' object is not iterable error.
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser=webdriver.Chrome()
browser.get('https://en.wikipedia.org/wiki/Main_Page')
search=[]
search=browser.find_element_by_xpath('//*[@href]')
for ii in search:
print(ii.get_attribute('href'))
time.sleep(4)
browser.close()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…