
VS Code로 실습해보았는데, '현대자동차'는 잘 나오지만, 'LG전자'가 나오지 않습니다.
VS Code로 할 때는 각각 print()로 해야될까요?



작성한 코드 및 에러 메세지
import requests
from bs4 import BeautifulSoup
def get_news(keyword):
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'http://13.125.227.101/finance_automation/?keyword={keyword}',headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
lis = soup.select('#main_pack > section.sc_new.sp_nnews._fe_news_collection._prs_nws > div.api_subject_bx > div.group_news > ul > li')
for li in lis:
a = li.select_one('a.news_tit')
print(a.text, a['href'])
get_news('현대자동차')
get_news('LG전자')
