如何修复“WebElement”对象没有属性“append”问题?

问题描述 投票:0回答:1

我正在尝试进行网络抓取,但我不断收到此错误......

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()
selenium-webdriver web-scraping
1个回答
0
投票

这个

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

应该是

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

mails
是 Selenium-Python 中的列表。您无法对其调用
.text

同样,您必须在代码中的多个位置进行更改。

© www.soinside.com 2019 - 2024. All rights reserved.