Skip to content

Feature/scraper for piter com#29

Merged
khoshov merged 10 commits intodevelopfrom
feature/scraper_for_piter_com
Jul 17, 2025
Merged

Feature/scraper for piter com#29
khoshov merged 10 commits intodevelopfrom
feature/scraper_for_piter_com

Conversation

@BerdyshevEugene
Copy link
Collaborator

No description provided.

logger = setup_logger(module_name=__name__, log_dir="logs/scrapers")


class AsyncBookFetcher(BaseScraper):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется лучше вынести в отдельный модуль

"cover": parser.extract_cover_image(),
}
logger.debug(f"parsed book data for: {book_data['book_title']}")
return book_data
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Посмотреть весь пул реквест на соответствие принципам SOLID (на первом месте SRP, на втором DI, остальные по желанию)

SOLID habr

SOLID claude

parser = BookParser(html)
book_data = {
"url": url,
"book_title": parser.extract_book_name().get("book_title", ""),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот тут для меня выглядит странно, почему не обработать внутри метода



class BookParser:
def __init__(self, html: str, base_domain: str = "https://www.piter.com"):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.piter.com я бы вынес куда-то в глобальную переменную

if name_tag:
full_name = name_tag.get_text(strip=True)
parts = full_name.split()
if len(parts) == 1:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

123 - антипаттерн magic numbers

return book_data


class Command(BaseCommand):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно добавить docstrings и type hints

@khoshov khoshov merged commit 3535c06 into develop Jul 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments