import refrom bs4 import BeautifulSoup# no other imports are allowed# notes# we have provided two files, "dell_laptop.html", and "dell_laptop_files.zip".# your `scrape_dell_laptop` function should be...

import refrom bs4 import BeautifulSoup# no other imports are allowed# notes# we have provided two files, "dell_laptop.html", and "dell_laptop_files.zip".# your `scrape_dell_laptop` function should be able to scrape a file with# similar structure to "dell_laptop.html".# the "dell_laptop_files.zip" contains the files to make the html page look# nice, and will make the html page show as it appears on Amazon. you don't# need these additional files to complete the assignment, but if you want to# have "dell_laptop.html" show as it appears on Amazon, then you can unzip the# folder. then, place the "dell_laptop.html" file outside this unzipped folder,# and when you open "dell_laptop.html", the page should look just like it# appears on Amazon.# you may get an error that "path too long" when unzipping the file. if you# run into this, open the zipped folder, and then just drag and drop the# dell_laptop_files to where you want to unzip the files to.# - general hint: use your browser's inspect element functionality# to find the pieces you needdef scrape_dell_laptop(filename): """ Parses a html file, and the name of the html file is passed in through the `filename` parameter. Returns a list of dictionaries representing the Amazon search results. When opening the file, use encoding='utf-8' as an argument. The file will have the same structure as the provided example dell_laptop.html Returns: list of dict, where each dict represents an item in the search results from Amazon. each dict is formatted as such (note the types for values): { "price": float, "title": str, "display_size": str, "rating": float } the dicts will appear in the order they are shown in the search results example of a dictionary in the final output: { 'price': 1733.32, 'title': 'Dell XPS7390-7954SLV-PUS 13.4-inch FHD Laptop (Silver)', 'display_size': '13.4 inches', 'rating': 4.1 } Notes: - if there is no default price on the product, it is marked as -1.0 - if there is no visible rating on the product, it is marked as -1.0 - display_size does not have a notable tag - think about using other methods to find a specific group of characters (*hint* regex)
Oct 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here