Home > Enterprise >  How can I fix 'WebElement' object has no attribute 'append' issue?
How can I fix 'WebElement' object has no attribute 'append' issue?

Time:11-02

I am trying to do a web scrape but I am getting this error continuously...

Kulup_button = browser.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/a/div/div[1]/div") #ilk kulüp için sonra değiştir
Kulup_button.click()    
time.sleep(1)

for i in range(1): 
    browser.execute_script('window.scrollTo(0,document.body.scrollHeight)') #sayfayı aşağıya doğru çekmek için
    time.sleep(1)


mails = browser.find_elements_by_css_selector("#bilgiler > a.btn.bg-orange.btn-social")
MailList=[] 

for MailList in mails: 
    MailList.append(mails.text) 
    
    
FacebookAdres = browser.find_element_by_class_name("btn bg-blue btn-social") 
FacebookList=[] 

for FacebookList in FacebookAdres: 
   FacebookList.append(FacebookAdres.text)    
    
TwitterAdres = browser.find_element_by_class_name("btn btn-social bg-aqua") 
TwitterList=[] 

for TwitterList in TwitterAdres: 
   TwitterList.append(TwitterAdres.text) 
   
   
InstagramAdres = browser.find_element_by_class_name("btn btn-social bg-light-blue") 
InstagramList=[] 

for InstagramList in InstagramAdres:
   InstagramList.append(InstagramAdres.text) 

kulupadi = browser.find_element_by_xpath("/html/body/div[2]/div[2]/section/div/div[2]/div/div[1]/div/div[1]/table/tbody/tr[1]/td[1]")
kulupList=[]

for kulupList in kulupadi:
    kulupList.append(kulupadi.text)     

AkademikDanisman = browser.find_element_by_xpath("/html/body/div[2]/div[2]/section/div/div[2]/div/div[1]/div/div[1]/table/tbody/tr[2]/td[1]/b")
DanismanList=[] 

for DanismanList in AkademikDanisman: 
   DanismanList.append(AkademikDanisman.text)      

KulupBaskani = browser.find_element_by_xpath("/html/body/div[2]/div[2]/section/div/div[2]/div/div[1]/div/div[1]/table/tbody/tr[3]/td[1]/b") #her bir bağlantımın bilgilerini alabilmek için "elements"
BaskanList=[] 

for BaskanList in KulupBaskani: 
   BaskanList.append(KulupBaskani.text)  

ToplamUye = browser.find_element_by_xpath("/html/body/div[2]/div[2]/section/div/div[2]/div/div[1]/div/div[1]/table/tbody/tr[4]/td[1]/b")
UyeList=[] 

for UyeList in ToplamUye: 
   UyeList.append(ToplamUye.text)  

ToplamEtkinlik = browser.find_element_by_xpath("/html/body/div[2]/div[2]/section/div/div[2]/div/div[1]/div/div[1]/table/tbody/tr[5]/td[1]/b")
EtkinlikList=[] 

for EtkinlikList in ToplamEtkinlik: 
   EtkinlikList.append(ToplamEtkinlik.text)  


time.sleep(5)

browser.quit()

CodePudding user response:

This

mails = browser.find_elements_by_css_selector("#bilgiler > a.btn.bg-orange.btn-social")
MailList=[] 

should be

mails = browser.find_elements_by_css_selector("#bilgiler > a.btn.bg-orange.btn-social")
MailList=[]
for mail in mails:
    MailList.append(mail.text)

mails is a list in Selenium-Python. You can't invoke .text on it.

Similarly, you will have to make changes at several places in your code.

  • Related