NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Data Visualization > Scraping Craigslist (Cars+Trucks)

Scraping Craigslist (Cars+Trucks)

Radhey Shyam
Posted on May 27, 2016

Contributed by Radhey Shyam. He  is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his third class project -Python web scraping (due on the 6th week of the program).

Introduction:

For my web scraping project , I chose Craigslist website. I really like its concept and  even I bought my first car from a craigslist seller and it was much cheaper than dealers. I spent lot of searching on craigslist wondering what was the best time to find the deal. As from my search,I found that a good car deal do not last for a  long time. It will be really helpful  if you can find out the most probable day and time when people place the ad so that you can reply promptly. Secondly, I wanted to analyze the price range,make and model year of the cars/trucks on the website.

Methodology:

For scraping craigslist, I picked  cars & trucks (owners) section of New York craigslist. To scrap the data,I used scrapy and PyCharm ,which is an Integrated Development IDE) for Python.  The main scarping file imports a Spider class from Scrapy package.The spider class is where we define how the website will be scarped, allowed urls and starting urls. First, I defined the allowed urls for the craigslist website , and staring url of the webpage. I checked the main page of the website and found out that only first 100 car ads are posted on the main search page.There were in total 25 pages of ads, each page consisting of 100 ads.I found the pattern of next page listings as starting url "+ ?s=i*100" . Next ,I created a list of urls of all pages using a for loop as shown below.

Next , I setup how the webpage will be scraped. As each page consists of 100 ads, I scraped the ad ids (100) contained in the page  and stored them in a list. Then for each ad, I created complete web address by concating the main web url with ad id  plus html.Then I sent parse request for each ad page and parsed the price, title, posting time and body of the ad and stored the data in a csv file and code for the same is shown below.

Next step was to clean the parsed data.In car price data, I found that sometimes people also listed used car parts in car sale section and their price was usually less than $300. I removed all the entries having price less than $300. The price histogram of all the car ads is shown below and I chose bin size of $500 for the histogram. The range of car price was from $300 to $110,00 with median price of $4800. Below is shown the histogram of car prices in the range of $300-$20,000.

 

price_hist

As we can see from above price histogram that peak sales of 180 counts happens in the price range of $3000-$3500 and the price count drop drastically to 30 above price range of $10,000. I think that it makes sense that people normally used craigslist for selling used car under $10,000 and it will be hard to sell costly cars on the craigslist.

Another curiosity was to find that whether  people prefer  any day or time to post their ad on craigslist ?To find the posting day, I went to each car ad's detailed listing page and parsed  the posting date on the bottom of the page and stored in post_date variable as string. Then I convert the string to date format and then  used R's base class function,strftime() to extract weekday from the ad posting date.

weekday

As we can see from above bar chart of weekdays that the peak day for the posting the ad was Friday, followed by Wednesday and Saturday. I think that people post car ads on Friday so that their ads remain fresh ( on top search page) during weekend and they have enough time for giving the car trials on weekend. Also, from my personal experience, people respond to the newer posted ads on weekends and it is easy to take calls and gave car trial on weekends.  The only surprise to me was Wednesday as it is in the middle of the week and but I think that people were getting ready for the weekend to sell the car.

Next, I was curious about the time of placing the ad and whether people prefer any time for placing the car.This time, I separated the time from the as post date field and converted them to 24 hour time by adding 12 to pm time and rounded them by the hour.

weekday_time_violin

The above violin plot are sorted by increasing count of the ads from let to right. There is interesting peak at 9 am on Saturday,  as more sellers place their ad on Saturday in between 9 am to 9:59 am than other time of day. So , if you are a buyer and looking for new ads,then this is time you should look for on Saturdays so that you cannot miss a good deal. Also, count density on Saturday becomes narrower as the day progresses, and you are less likely to find fewer new ads as the day progresses. Also,there is a peak around the same time at 9 am on Friday and Saturday. And There is very few or no activity from midnight till 4 am in the morning on all days.

Next, I searched the title of the ads for most common words.While analyzing the titles , I removed all the numbers and characters and created a word cloud using R language's  word cloud library and it is shown below.

title_word_cloud2

The size of the words are proportional to their frequency in the title of the ads. The most common words in the title were make of the cars: Honda, Ford,Chevy,Hyundai,bmw, sale, low miles,clean ..

Finally,  I want to know most common model years of the cars.For that , I separated the numbers from the title and created a word cloud of the numbers from size 4(2005)  to 2 (05) as shown below.

model_years

 

The size of the years in the word cloud  tells the frequency of the years in the title. The most common model years were 2005,2006,2004 (it shows that people commonly sell cars which are 10 years or old on the craigslist ) and 2009 ( 5 plus years or so).

Conclusion:

  • Price histogram  peaks in the range $3000-$4000 and it drops significantly after the price range of $7500-$8000.
  • Friday is the most common day to put ad and it closely followed by Wednesday and Saturday.
  • Saturday  9-10 am is the most common time to place ad , if you are looking for used car, then it is the best time to check the craigslist for new ads.
  • Most frequency words  in title are Honda, Ford,Chevy,Hyundai, bmw, sale, low miles,clean.
  • Most common year of the car  models  are 2005,2006,2004  or  2009 (5 years ) or 2013 or 2015 (3 years old or less ).

Future Directions:

I  would like to analyze other details of the ads by looking at the detailed body of the ads and some other optional fields  like mileage, wheel drive,condition of the cars found on the detailed page. If I can get access to some historical data, I would like to predict the probability of the selling car depending on various factors.

If you have comments, questions or suggestions, please let me know.

About Author

Radhey Shyam

Radhey Shyam received his Ph.D. in Physics from Clemson University, USA and M.S. (Computer Science & Engineering) from GJU of Science & Technology, India. Radhey Shyam did his master's thesis on Network Monitor System, where he applied innovative...
View all posts by Radhey Shyam >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

Leave a Comment

Cancel reply

You must be logged in to post a comment.

kayhughes December 1, 2023
Basketball stars unblocked is a thrilling 2-player basketball game created by Madpuffers Link: https://basketballstarsunblocked.io
kayhughes December 1, 2023
basketball stars unblocked is a thrilling 2-player basketball game created by Madpuffers
Google February 8, 2021
Google Usually posts some extremely interesting stuff like this. If you are new to this site.
Google January 8, 2021
Google Every when inside a although we pick out blogs that we read. Listed beneath are the most up-to-date internet sites that we pick out.
Google October 13, 2019
Google Always a huge fan of linking to bloggers that I adore but donย’t get a lot of link enjoy from.
Google October 8, 2019
Google One of our guests not long ago proposed the following website.
judi poker deposit 10rb February 6, 2019
So, it's easy to note that you may make bets with low house advantages whilst still being be fairly all-around a 50-50 game. By using cash profit zones, you're not playing from the casino, you might be playing against yourself, now this is very very important. If you bond with other people's experiences, it's easy to find out which casinos are fair and truthful and that are controversial.
Gregory September 29, 2018
Oops
Abdelmajid Lotfi August 22, 2018
Hi, where is the complete code ? and how to run it ? Thanks.
Alex November 24, 2017
I've been doing some web-scraping on Craigslist as well. However, my IP has just been blocked. I'm pretty sure it's because of how many request my program made in such a short time. Did you encounter the same problem? I emailed their support team, but I'm still looking for how I can avoid this in the future.
Christian Goldman July 18, 2017
I came across nycdatascience.edu/blog and it seems your site would really benefit from our private targeted traffic system. There are two ways you can increase your success online, either improve your sales message or increase the quality/quantity of your traffic. We help you with BOTH! -- With this webmaster deal you can try our SEO/Analysis & Traffic System totally free. Don't miss out, this is a limited time offer! Start your free trial today: http://autoprofit.info/rush/1/AQnlineXdiCsounTx/ Questions? Email : christian@autoprofit.info // Unsubscribe: http://autoprofit.info/unsub/28904/QskskjcsXcsdD/
Pasquale January 3, 2017
Valuable information. Lucky me I discovered your site accidentally, and I am shocked why this twist of fate didn't came about in advance! I bookmarked it.
Craigslist posting October 13, 2016
That is very fascinating, You're a very professional blogger. I have joined your feed and stay up for looking for more of your great post. Additionally, I've shared your web site in my social networks
JimmyLKunc September 24, 2016
I am sure this post has touched all of the internet viewers, its really really pleasant paragraph on building up new weblog.
fake bvlgari bzero1 ring September 11, 2016
$SPX is at or slightly above the 61.8% Fib fan. Obviously, it hasn't broke 1090 (yet). Bulls need to keep this up and, ideally, close higher. fake bvlgari bzero1 ring http://www.bzero1jewelry.net/
YaelAFalacco August 27, 2016
Your personal style is incredibly unique when compared with other folks I have got read stuff from. I appreciate you posting in case you have the chance, Guess I will just bookmark this page.
fifa 17 coins August 21, 2016
I love this site - its so usefull and helpfull fifa 17 coins http://mortelbox.com/event/1219
fifa 17 August 17, 2016
Wow, beautiful portal. Thnx ..
madden 17 August 16, 2016
Extremely individual friendly website. Astounding information readily available on few clicks on
madden 17 coins August 15, 2016
Whoa, such a handy internet site
muscle cars July 25, 2016
Greetings from Idaho! I'm bored to tears at work so I decided to check out your blog on my iphone during lunch break. I really like the information you provide here and can't wait to take a look when I get home. I'm surprised at how quick your blog loaded on my cell phone .. I'm not even using WIFI, just 3G .. Anyhow, great blog!
ford mustang July 3, 2016
Very goโฒŸd info. Lucky me โ…  discovered าฏโฒŸur site bส chance (stumbleupon). ฮ™ havแฅฑ book-marked ั–t fะพr latะตr!
craigslist list search June 24, 2016
I do not even know how I ended up here, but I thought this post was good. I do not know who you are but certainly you're going to a famous blogger if you aren't already ;) Cheers!

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application