Question: use the web scraping methods that were covered in class to gain competitive intelligence on used cars. As your source, please use the recommended car
use the web scraping methods that were covered in class to gain competitive intelligence on used cars. As your source, please use the recommended car dealership site that was provided with the sample code for this exercise. Please also use Jupyter Notebook to run your code.
URL1: https://www.cargurus.com/Cars/inventorylisting/viewDetailsFilterViewInventoryListing.action?zip=73301&distance=50&sortType=DEAL_SCORE&entitySelectingHelper.selectedEntity=d1512&showNegotiable=true&sortDir=ASC&sourceContext=carGurusHomePageModel
URL2: https://www.cargurus.com/Cars/inventorylisting/viewDetailsFilterViewInventoryListing.action?zip=90210&showNegotiable=true&sortDir=ASC&sourceContext=carGurusHomePageModel&distance=50&sortType=DEAL_RATING_RPL&entitySelectingHelper.selectedEntity=d1512
Task 4-1: Pick a car make and model of your choice. Select two different cities or locations that you are interested in getting competitive data of your selected car. Extract the prices of your selected car for each of the locations you've identified by using the web scraping code provided. Visualizations of your results are encouraged here.
Task 4-2: Determine the average price point for your selected car in each of the locations identified.
Task 4-3: Calculate the depreciation of the car you've selected across the two locations identified. Compare this value across the two locations. Note: You have to use a depreciation formula to determine the depreciation of the car.
Task 4-4: provide a competitive intelligence report describing your findings for tasks 4-1 to 4-3. Provide your recommended price for a 3-year-old car of the model you've selected in both cities.


Comparison of Prices through Web scraping import bs4, requests import re import pandas as pd import numpy as np import json from re import sub from decimal import Decimal [2] url= 'https://www.cargurus.com/Cars/inventorylisting/viewDetailsFilterViewInventoryListing.action?sourceContext=carGurusHomePageModel&entitySelectingHelper.selectedEntity-d1512&zip=02215 BMW 3 Series in Boston Hur12 = "https://www.cargurus.com/Cars/inventorylisting/viewDetailsFilterViewInventoryListing.action?zip-98218&showNegotiable=true&sortDir=ASC&sourceContext=carGurusHomePageModel&distance-58&sortType=DEAL_RATING_RPL&entitySelectingHelper.selectedEntity=d1512* res = requests.get(ur1) [3] soup = bs4. BeautifulSoup(res.text) llprint (soup.prettify()) [4] #find data in dictionary format dataset soup.find_all("script") dictionary = [] for data in dataset: data strstr(dictionary) dict object = json.loads (re.search('({.+})', data_str).group(0).replace(***, ***)) print(type(dict_object)) #print(dict_object) #print(type(data)) #print(data) if 'PREFLIGHT' in str(data): dictionary.append(data) #print('found') [5] for key, value in dict_object.itens(): #print(key) break listings = dict_object["listings"] #print (type(listings)) #print(listings) output frame = pd.DataFrame(columns = ["Title", "Price", "Mileage', "Year']) for car in listings: 0 1 2 3 4 5 output_frame year car['carYear'] title = car["listingTitle"] price = car['price"] mileage car['mileage'] output_frame.loc[len(output_frame.index)] = [title, price, mileage, year] Title Price Mileage Year 8. 2021 BMW 3 Series 330i xDrive AWD 33590.0 32426 2021 25364 2020 25753 2021 18468 2020 20211 2020 2020 BMW 3 Series 330i xDrive Sedan AWD 34498.0 2021 BMW 3 Series 330i xDrive AWD 35988.0 2020 BMW 3 Series 330i xDrive Sedan AWD 34798.0 2020 BMW 3 Series 330i xDrive Sedan AWD 34798.0 2020 BMW 3 Series 330i vDrive Serian AWD 33008 0 30735 2020
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
