
* 겪고 있는 제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
안녕하세요
1-5 업무자동화 엑셀다루기 따라하는데 코드 실행이 안됩니다.
어디서 뭐가 틀렸는지 모르겠어요 ㅠ


!pip install bs4 requests
-------------------------------------------------
import requests
from bs4 import BeautifulSoup
from openpyxl import Workbook
def get_news(keyword):
wb= Workbook()
sheet = wb.active
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get(f'https://search.naver.com/search.naver?where=news&ie=utf8&sm=nws_hty&query={keyword}',headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
lis = soup.select('#main_pack > section > div > div.group_news > ul > li')
for li in lis:
a = li.select_one('a.news_tit')
row = [a.text, a['href']]
sheet.append(row)
wb.save(f"{keyword}.xlsx")
wb.close()
---------------------------------------------------
get_news('삼성전자')
------------------------------------------------
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-82724b372f00> in <module>
----> 1 get_news('삼성전자')
1 frames
<ipython-input-12-80c861dd4812> in get_news(keyword)
20 a = li.select_one('a.news_tit')
21 rows = [a.text, a['href']]
---> 22 sheet.append(row)
23
24 wb.save("{keyword}.xlsx")
/usr/local/lib/python3.8/dist-packages/openpyxl/worksheet/worksheet.py in append(self, iterable)
658 cell = content
659 if cell.parent and cell.parent != self:
--> 660 raise ValueError("Cells cannot be copied from other worksheets")
661 cell.parent = self
662 cell.column = col_idx
ValueError: Cells cannot be copied from other worksheets
