Skip to content

Python Week 3 Project Review: Price Scraper + Currency Converter #1

Description

@bonareri

Requirements Checklist

Requirement Marks
Scrape at least 10 products using requests and BeautifulSoup 25/25
Store product name and original price 15/15
Use a currency conversion API 20/20
Convert prices correctly 15/15
Save data to CSV or JSON 15/15
Display products in a readable table using pandas/tabulate 15/15
Error handling for connection issues 14/15
Code quality, organization, and readability 2/5
Optional extensions (currency selection, timestamp, visualization) 0/5
Total 116/125

Strengths

  • Successfully scraped more than the required 10 books from the Books to Scrape website.
  • Retrieved live exchange rates using a valid Exchange Rate API.
  • Correctly converted book prices from GBP to KES.
  • Cleaned the scraped price data using regular expressions.
  • Displayed the final dataset in a clean and readable table using pandas.
  • Successfully exported the results to a CSV file.
  • Included exception handling for both the API request and website request.
  • Implemented a fallback exchange rate if the API request failed, ensuring the program could still run.
  • Used descriptive print statements to clearly indicate the progress of each step, making the program easy to follow.

Areas for Improvement

1. Code Organization

Most of the code is written in the global scope. Organizing the program into reusable functions such as:

fetch_exchange_rate()
scrape_books()
display_results()
save_to_csv()
main()

would improve readability, maintainability, and make future enhancements easier.


2. Unused Imports

The following imports are not used in the project:

import csv
import json

Removing unused imports would improve code cleanliness.


3. Error Handling

The project includes good error handling for network requests. However, using:

exit()

to terminate the program after a failed website request is not ideal. Returning from a main() function or handling the failure more gracefully would make the application more robust.


4. Optional Extensions

The assignment suggested implementing additional features such as:

  • Allowing users to choose the currencies.
  • Adding a timestamp to the output.
  • Plotting a bar chart comparing original and converted prices.

None of these optional extensions were implemented.


Optional Extensions

Extension Status
User chooses currencies Not implemented
Timestamp added to output Not implemented
Bar chart comparing original and converted prices Not implemented

Final Score: 116/125

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions