import requests from bs4 import BeautifulSoup # BeautifulSoup import response = requests.get('https://movie.daum.net/ranking/reservation') html = response.text soup = BeautifulSoup(html, 'html.parser') # html.parser를 사용해서 soup에 넣겠다 ranking = 1 r_soup=soup.select('div[class=wrap_cont]') num=0 while num<5: name=r_soup[num].select('div[class="info_tit"] a[class=tit_main]') score=r_soup[num].select('dd[class=score] em') # print(tag.text) # ranking = ranking + 1 # print(tag.get('href')) if len(score)>0: real_score=score[0].text else: real_score='' print(name[0].text, real_score) n_url=name[0].get('href') n_response = requests.get('https://search.daum.net/search'+n_url) n_html=n_response.text n_soup=BeautifulSoup(html, 'html.parser') nr_soup=n_soup.select('div[class="card_comp"] ul[class="c-list-basic"] li div[class="c-item-content"] div[class="item-title"] a') for title in nr_soup: news_title=title.text print(news_title) num=num+1 print("---------------------") #conts-combo #