def parser(back_post_id):
URL = "https://habr.com/ru/search/?q=python&target_type=posts&order=date"
page = requests.get(URL)
soup = BeautifulSoup(page.content, "html.parser")
post = soup.find("article", class_="tm-articles-list__item", id=True)
post_id = post["id"]
if post_id != back_post_id:
title = post.find("a", class_="tm-article-snippet__title-link").text.strip()
description = post.find("p", class_="article-formatted-body article-formatted-body article-formatted-body_version-2")
url = post.find("a", class_="tm-article-snippet__title-link", href=True)["href"]
return f"{title}\n\n{description}\n\n{url}", post_id
else:
return None, post_id