words = ('sleepy','졸린','coffee','drink','마시다')
import requests
from bs4 import BeautifulSoup
url = "http://dic.daum.net/search.do?q="</span><span style="color: rgb(51, 51, 51); text-transform: none; text-indent: 0px; letter-spacing: normal; font-size: 12px; font-style: normal; font-weight: 400; word-spacing: 0px; float: none; display: inline !important; white-space: pre-wrap; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
try:
for i in words :
response = requests.get(url+i)
plain_html = response.text
html = BeautifulSoup(plain_html, "html.parser")
eng_dictionary = html.find(attrs={'class':'card_word #word #eng'})
search_word_box = eng_dictionary.find(attrs={'class':'search_box #box'})
search_word = search_word_box.find(attrs = {'class':'txt_cleansch'}).get_text()
list_search = search_word_box.find(attrs = {'class':'list_search'}).get_text()
print(search_word,list_search)
except :
continue
이렇게했거든 ㅠ
컨티뉴가 저 앞에 for에 걸려야하는데 안걸린다는거지?
엉 ㅠㅠ 'continue' not properly in loop 에러이거뜸 ㅠ.
걸릴리가?
뭐가문제인거야 ㅠ 프알못이라 시발.. 암거도몰라 ㅠㅠ
컨티뉴가 걸리려면 for문안에 들어가야지
try에서 에러뜨면 continue 걸라구 하는게 문제인거같은데 ㅠ exception 밑에다가 continue 넣어주면 자동으로 걸어주는거아니였어?? ㅠ
try내용이랑 except내용이랑 별개라고 생각하면됨 try내용에서 예외가 발생하면 try 무시하고 대신 except을 실행하라는 뜻임
강의 피피티에 try except 구문 (4)오류가 발생하면 다음 단어를 검색해보자. except 블록 안에는 continue 명령어를 넣어 다음 순서의 for문으로 접근하게 한다.
이래되잇어서 ㅅㅂ.. 내가이해를못하고있는거지지금
for문 안에 try except넣어
아씨바 댓다 형들고마워 ㅠㅠㅠ