https://m.search.naver.com/search.naver?where=m_news&query=1%EB%B3%B4&sm=mtb_tnw&sort=1
How do I route the subject of the article exposed in the link above to get 20 article titles, starting with the most recent one?
I found the api_txt_linesit, but I don't know what to do next.
python crawling naver
Beautiful Soup makes it easy to implement.
Python code to print the title of the breaking news article.
from bs4 import BeautifulSoup
import urllib.request
# Import html source
url = 'https://m.search.naver.com/search.naver?where=m_news&query=1%EB%B3%B4&sm=mtb_tnw&sort=1'
with urllib.request.urlopen(url) as response:
html = response.read()
soup = BeautifulSoup(html, 'html.parser')
articles = soup.found_all('div', {'class': 'api_txt_linesit'}) # Get article title
# To print out the article title
for article in articles:
title = article.text
print(title)
© 2024 OneMinuteCode. All rights reserved.