Skip to content
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

Develop #366

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Develop #366

wants to merge 4 commits into from

Conversation

xborismenx
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this project! 😊 While your code is well-structured and meets most of the task requirements, there are a couple of critical issues that need to be addressed before we can approve the Pull Request:

  1. Error Handling in get_single_quote: The function currently assumes that the elements it searches for will always be present. This could lead to an IndexError if the expected elements are missing. Please add checks to ensure that find_all returns a non-empty list before accessing elements.

  2. Handling HTTP Responses: It's important to verify that the HTTP request was successful before accessing the content. Please modify your code to check response.status_code to ensure it's 200 before proceeding with accessing response.content.

Once these issues are resolved, your code will be more robust and ready for approval. Keep up the great work, and don't hesitate to reach out if you need any help! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/parse.py Outdated
url = HOME_PAGE_URL
while url:
try:
response = requests.get(url).content

Choose a reason for hiding this comment

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

The requests.get(url).content should be checked for a successful response status before accessing .content. Consider using response = requests.get(url) and then checking response.status_code to ensure it's 200 before proceeding.

app/parse.py Outdated
Comment on lines 18 to 20
text = single_quote.find_all("span", class_="text")[0].text
author = single_quote.find_all("small", class_="author")[0].text
tags = [elem.text for elem in single_quote.find_all("a", class_="tag")]

Choose a reason for hiding this comment

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

The get_single_quote function assumes that the elements it searches for will always be present. Consider adding checks to ensure that find_all returns a non-empty list before accessing [0].text to avoid potential IndexError.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Your code has been reviewed and approved! 🎉 While there are a few areas for improvement, such as optimizing the redundant call to page_with_quotes and enhancing the clarity of error messages, your solution meets the task requirements. You've successfully implemented error handling for missing elements and HTTP response checks, which are crucial for robust code. Moving forward, please address the highlighted issues to enhance efficiency and maintainability. Keep up the great work and continue learning from these experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +58 to +59
if page_with_quotes(soup):
block_quote = page_with_quotes(soup)

Choose a reason for hiding this comment

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

The function page_with_quotes is called twice here. You can optimize this by calling it once and storing the result in a variable, then using that variable in the condition and the subsequent code.

all_quotes.extend(quotes.__dict__ for quotes in parsed_quotes)
url = next_page(soup)
except requests.RequestException as e:
print(f"When parse got error {e}")

Choose a reason for hiding this comment

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

The error message 'When parse got error' is not very descriptive. Consider providing more context or details about the error to aid in debugging.

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