
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
아래와 같은 에러가 뜨는데 왜 안되는지 모르겠습니다,,
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from smtplib import SMTP_SSL
from email.message import EmailMessage
import time
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])
browser = webdriver.Chrome(options=chrome_options)
MY_KEYWORD = '전기자동차'
#웹사이트 열기
browser.get('https://news.google.com')
time.sleep(1)
search = browser.find_element(By.CSS_SELECTOR, '.Ax4B8')
search.click()
search.send_keys(MY_KEYWORD)
time.sleep(2)
search.send_keys(Keys.ENTER)
time.sleep(2)
before_h = browser.execute_script("return window.scrollY")
while True:
browser.find_element(By.CSS_SELECTOR, "body").send_keys(Keys.END)
time.sleep(1)
after_h = browser.execute_script("return window.scrollY")
if after_h == before_h:
break
before_h = after_h
time.sleep(1)
item_list = browser.find_elements(By.CSS_SELECTOR, '.ipQwMb')
article_list = []
for item in item_list:
content = item.find_element(By.CSS_SELECTOR, 'a')
title = content.text
link = content.get_attribute('href')
#print(title, link)
item_dict = {'title' : title, 'link' : link}
article_list.append(item_dict)
browser.quit()
#이메일 메시지 설정
send_email = 'mercuri.park@gmail.com'
password = 'oqwl hhxm bxdi rgsn'
receive_email = ['mercuri.park@gmail.com']
for customer in customer_list:
msg = EmailMessage()
msg['Subject'] = '[AUG테크] 오늘 전기자동차 관련 뉴스 입니다.'
msg['From'] = send_email
msg['To'] = receive_email
email_body = ''
for article in article_list:
title = article['title']
link = article['link']
email_body += title
email_body += link
msg.set_content('This is a test email')
#SMTP 설정 및 이메일 전송
with SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(send_email, password)
smtp.send_message(msg)
print("성공!")
작성한 코드 및 에러 메세지
(.venv) PS C:\Users\Chloe\OneDrive\바탕 화면\crawling> & "c:/Users/Chloe/OneDrive/바탕 화면/crawling/.venv/Scripts/python.exe" "c:/Users/Chloe/OneDrive/바탕 화면/crawling/4.mail_auto/news.py"
File "c:\Users\Chloe\OneDrive\바탕 화면\crawling\4.mail_auto\news.py", line 50
article_list.append(item_dict)
^
IndentationError: unindent does not match any outer indentation level
