-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #358
base: master
Are you sure you want to change the base?
solution #358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the code to scrape quotes from the website! 🎉 Your solution meets the task requirements and successfully handles pagination to gather all quotes. The code is well-structured and writes the data into a CSV file as expected.
There are a few minor improvements you could consider for future projects:
- Function Naming: Renaming
get_all_quote
toget_all_quotes
would make the function name more intuitive. - Error Handling: Adding checks to ensure elements like
.author
,.text
, and.tags
are present before accessing them would make your code more robust and prevent potential errors.
These are minor issues and don't affect the core functionality, so I'm happy to approve your work. Keep up the excellent work and happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
) | ||
|
||
|
||
def get_all_quote() -> [Quote]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name get_all_quote
should be pluralized to get_all_quotes
to accurately reflect that it returns a list of quotes.
tags = quote_soup.select_one(".tags").text.split("\n") | ||
cleaned_list_tags = [ | ||
tag.strip() | ||
for tag in tags | ||
if tag.strip() and tag.strip() != "Tags:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parse_single_quote
function assumes that the .tags
element and its text are always present. Consider adding error handling to manage cases where these elements might be missing.
if tag.strip() and tag.strip() != "Tags:" | ||
] | ||
return Quote( | ||
text=quote_soup.select_one(".text").text, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, ensure that the .text
element is present before accessing its text to avoid potential errors.
] | ||
return Quote( | ||
text=quote_soup.select_one(".text").text, | ||
author=quote_soup.select_one(".author").text, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the .author
element is present before accessing its text to avoid potential errors.
No description provided.