작업의 텍스트를 인쇄하려고합니다. 불행하게도, HREF는 전혀 표시하지 유지하고 나는 다음과 같은 오류 얻을 텍스트 인쇄 오류가 점점 계속 : 나는이 같은 변화를 시도 hereAttributeError : 'str'객체에 'text'속성이 없습니다. CSS 오류가 발생했습니다.
with open('Aperture Science.csv', 'a+', newline='\n') as file:
writer = csv.writer(file)
for section in sections:
try:
link = section.find_element_by_css_selector("h3 a").get_attribute("href")
print((section.get_attribute('href')))
except NoSuchElementException:
pass
time.sleep(7)
try:
team_name = section.find_element_by_css_selector(".row:nth-child(1) td:nth-child(1)").text
print(section.text)
except NoSuchElementException:
pass
time.sleep(7)
try:
bet = section.find_element_by_css_selector(".odds .odds span").text
print(bet.text)
except NoSuchElementException:
pass
time.sleep(7)
writer.writerow((bet, team_name, link))
아래
Traceback (most recent call last):
File "C:/Users/Bain3/PycharmProjects/untitled4/Bookmaker improved ALTERNATIVE.py",
line 155, in <module>
print(bet.text)
AttributeError: 'str' object has no attribute 'text'
코드 또는 전체 코드 :
for section in sections:
try:
link = section.find_element_by_css_selector("h3 a").get_attribute("href")
print((link.get_attribute('href')))
뿐만 아니라 :
team_name = section.find_element_by_css_selector(".row:nth-child(1) td:nth-child(1)").text
print(team_name.text)
print(section.text)
작동하지만 인쇄하고 싶은 텍스트가 아닙니다. 어떤 아이디어?
오류 – 0TTT0
@ 0TTT0 HTTP 다시 전체 추적을 게시하시기 바랍니다 .com/d4ej7 – Tetora
'bet = section.find ... (....). 텍스트'를 지정하고'bet.text'가 존재한다고 생각하십니까? –