Giter Club home page Giter Club logo

cars's Introduction

Webscraper of autotrader using Selenium

This project came about as my mum wanted to find a Citroen Berlingo to enjoy the festivals with this summer. My partner and I had recently written some scripts to scrape the Cazoo website in Python and I wrote a script to plot the cars in R using ggplot. More cars are on autotrader but this is a bit trickier to scrape as the autotrader website doesn't let you scrape it directly using a module in Python called "beautifulsoup", as it thinks you are a bot! I found autotrader also has an API which would be more stable than scraping. But I doubt this is free to use! I then came across a great script and set of clear instructions here: https://www.shedloadofcode.com/blog/how-to-scrape-autotrader-with-python-and-selenium-to-search-for-multiple-makes-and-models

Things I learnt from this project:

  • web scraping using python, beautiful soup, selenium
  • the debugging tool in PyCharm, conditional break points
  • how to get other people's code to work
  • how unstable webscraping can be
  • how to use the dev tools on the chrome browser, especially to hover over elements. This helped when fixing the bug where the code was excluding private sellers and I could compare the html for private sellers and dealerships.
  • explaining results to the client in non-jargon language

TL;DR

scrapeAT.py scrapes the autotrader website for Citroen Berlingos and writes to carsAT.csv. Code is tweaked from https://github.com/shedloadofcode/autotrader-selenium-scraper/blob/main/autotrader-scraper.py

Interpreting plot for the client (ie. my mum)

carsAT.png

Each point is a car. The darker the colour the cheaper the car. Cars/points in the bottom right quadrant that are a dark colour (ie. cheaper) are probably worth looking at on autotrader. To find the URLs for these cars download the carsAT.csv and find the car from the year, mileage and price from the plot.

Prerequisites

Data cleaning:

Also written in: scrapeAT.py

  • Removes duplicates (excluding the URL/link column). Some cars are duplicated because there are also adverts for the same car.
  • Fixed bug of missing data for the year by changing regular expression for removing "reg" from the "year" field.

Data plotting:

`exploreCarsAT.py creates the scatter plot above.

cars's People

Contributors

ameliaes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.