de-2410-a-challenges-web-scraping-web-scraping-activity created by GitHub Classroom
0
stars
0
forks
source link
As a BOOK STORE OWNER, I want to understand the average price point of books in each category from http://books.toscrape.com/, So that I can make decisions about the price point of different books for each category #2
[ ] The function should accept a URL as an input parameter.
[ ] The function should send an HTTP GET request to the provided URL using the requests library.
The function should handle the response:
[ ] If the response status code is 200, the function should return the HTML content of the page.
[ ] If the response status code is not 200, the function should return an error message indicating the status code and that the request was unsuccessful.
[ ] The function should catch any exceptions that occur during the request and return an appropriate error message.
Testing Requirements
Function 1 - Making a Request
Successful Request:
The function should receive a URL and make a GET request to the book.toscrape website.
The function should return the book data in JSON format if the response status code is 200.
Unsuccessful Request:
The function should return an error message if the response status code is not 200.
The error message should include the status code and indicate that the request was unsuccessful.
Exception Handling:
The function should catch any exceptions that occur during the request.
The function should return an error message indicating that an exception occurred.
Definition of Done
[ ] The function is implemented according to the functional requirements.
[ ] Unit tests are written to cover all testing requirements.
[ ] The function and tests are reviewed and approved by at least one peer.
[ ] The function is documented with clear and concise comments.
[ ] The code adheres to PEP 8 guidelines and Python best practices.
[ ] The function should query the supplied website using the result of the previously developed request_to_scrape function.
[ ] The function should return a dictionary, where the keys are the category names, populated with dictionaries where the link is a key and the value is the category URL.
[ ] The function should catch any exceptions that occur during the processing and return an appropriate error message, including not finding any relevant data in the HTML.
Testing Requirements
Successful Parse:
[ ] The function should return a dictionary, populated with dictionaries where the category name is the key and the value is a dictionary with the link as a key and the value is the category URL.
No Data Parse:
[ ] The function should return an error message if no categories are found in the HTML for the website.
Exception Handling:
[ ] The function should return an error message if an exception occurs during the processing.
Definition of Done
[ ] The function is implemented according to the functional requirements.
[ ] Unit tests are written to cover all testing requirements.
[ ] The function and tests are reviewed and approved by at least one peer.
[ ] The function is documented with clear and concise comments.
[ ] The code adheres to PEP 8 guidelines and Python best practices.
[ ] The function and tests are committed to the repository and pass all CI checks.
[ ] The functionality is demonstrated and verified in a development environment.
[ ] The function should extract the data from the HTML.
[ ] The function returns the correct categories and links.
Testing Requirements
Successful Extraction:
[ ] The function should return a dictionary, populated with dictionaries where the category name is the key and the value is a dictionary with the link as a key and the value is the category URL.
Exception Handling:
[ ] The function should return an error message if an exception occurs during the processing.
Definition of Done
[ ] The function is implemented according to the functional requirements.
[ ] Unit tests are written to cover all testing requirements.
[ ] The function and tests are reviewed and approved by at least one peer.
[ ] The function is documented with clear and concise comments.
[ ] The code adheres to PEP 8 guidelines and Python best practices.
[ ] The function and tests are committed to the repository and pass all CI checks.
[ ] The functionality is demonstrated and verified in a development environment.
Function 1 - Making a Request
Functional Requirements
requests
library.200
, the function should return the HTML content of the page.200
, the function should return an error message indicating the status code and that the request was unsuccessful.Testing Requirements
Function 1 - Making a Request
Successful Request:
200
.Unsuccessful Request:
200
.Exception Handling:
Definition of Done