Spaces:
Sleeping
Sleeping
File size: 471 Bytes
6eb8bc2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import requests
from bs4 import BeautifulSoup
url = 'https://www.cranberry.fit/post/ovulation-pain-unmasking-the-mystery'
response = requests.get(url)
try:
soup = BeautifulSoup(response.content, 'html.parser')
article_content = soup.find('article')
if article_content:
article_text = article_content.get_text(separator='\n', strip=True)
with open('blog.txt', 'w') as f:
f.write(article_text)
except Exception as e:
print(e)
|