Untitled
Anonymous
plain_text
09/29/2023 1:12 PM
808 B
30
Indexable
import requests
from bs4 import BeautifulSoup
url = 'https://vnexpress.net/'
try:
response = requests.get(url)
response.raise_for_status()
except requests.exceptions.HTTPError as http_err:
print(f"Có lỗi HTTP: {http_err}")
except requests.exceptions.RequestException as req_err:
print(f"Có lỗi trong quá trình gửi yêu cầu: {req_err}")
else:
soup = BeautifulSoup(response.text, 'html.parser')
title_tags = soup.find_all(class_='title-news')
for title_tag in title_tags:
title_text = title_tag.get_text().strip()
print(title_text)Editor is loading...