Data Scraping the Skyscrapers using Scrapy

Posted on Nov 10, 2016
Contributed by Conred Wang. He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between September 26th to December 23rd, 2016. This post is based on his third class project - Web Scraping Project (due on the 7th week of the program).
The skills we demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction

The Skyscraper Center publishes various types of data and information about the world's skyscrapers.

The Skyscraper Center

For example, the 100 Tallest Completed Buildings in the World by Height to Architectural Top :

Main Page of 100 Tallest Completed Buildings in the World by Height to Architectural Top.

The main page even includes a downloadable PDF.  However, some data, like year the skyscrapers were Proposed and Construction Start, is only available in secondary pages:

Secondary Page of 100 Tallest Completed Buildings in the World by Height to Architectural Top..

 

 

Scrapy

In order to obtain all the data we needed from the main and all secondary web pages, we used Scrapy.

An open source and collaborative framework for extracting the data you need from websites.  In a fast, simple, yet extensible way.

 

 

 

 

 

 

.


Data

 

cw-scrapy-cn

ct cc country ct cc country ct cc country
21 AE Arab Emirates 01 AU Australia 45 CN China
01 GB United Kingdom 01 KR South Korea 01 KW Kuwait 
03 MY Malaysia 03 RU Russia 02 SA Saudi Arabia
02 TH Thailand 02 TW Taiwan 17 US USA
01 VN Vietnam

 

Statistics about these 100 skyscrapers:

<Usages>

  • 40 are multipurpose
  • 74 are used for office.
  • 43 are used for hotel.
  • 29 are used for residential.
  • 2 are used for retail.

<Totals>

  • 7,758 floors.
  • 118,653 feet.

<Time>

  • 46 do not have Proposed Year listed.
  • 3 do not have Construction Start Year listed.
  • From Proposed To Construction Start:
    • Cannot compute 46.
    • Shortest took 0 year.
    • Longest took 9 years.
  • From Construction Start To Complete:
    • Cannot compute 3.
    • Shortest took 1 year.
    • Longest took 11 years.

Q : One year to build a skyscraper!  Really?

A : No kidding.  There are actually 2 skyscrapers:

cw-scrape-blgempste  

https://nycdsa-blog-files.s3.us-east-2.amazonaws.com/2016/11/cw.scrape.blgEmpSte.jpg


 

About using Scrapy

Scrapy is really easy and simple.

As depicted in the "A dataflow overview" diagram (below, which can be found at The ITC Prog Blog), we only need to write 3 short Python scripts ("items.py", "pipelines.py" and "skyscraper_spider.py"), and Scrapy did all the data extraction for us from the Skyscraper Center web pages:

cw-scrapy-dataflow

We included all 3 Python scripts below.

It is worth to mentioning that:

  • "scrapy shell <url>" and Google's Chrome inspect are the two indispensable tools when web scraping with Scrapy.
  • Although we love Scrapy, it is not perfect yet. For example, Scrapy will not tell you your Python code indentation is improper.
  • With UTF-8 encoding, the str function over text with unicode (for example, "u2026", horizontal ellipsis) will cause an exception.  Instead,  [<object>.encode('ascii','ignore')] can be used.  You can find an example on line 21 of "pipelines.py".
1. items.py
2. pipelines.py
3. skyscraper_spider.py

(end)

About Author

Conred

As a software engineer, scrum master and project management professional, Conred Wang believes in, "Worry less, smile more. Don't regret, just learn and grow.", which motivated him to study at NYCDSA and become a data scientist. His exposure...
View all posts by Conred >

Leave a Comment

reverse phone lookup January 24, 2017
411 reverse phone lookup actual free reverse phone lookup free reverse phone lookup with name free results

View Posts by Categories


Our Recent Popular Posts


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 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 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 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