Introduction to Scraping with Python Using 9 Lines of Code!

Includes code snippets to help you start immediately

Songtham Tung
Aug 12 · 2 min read
Photo by David Clode on Unsplash

Web Scraping is extracting data from websites. In this article, I will show you how to scrape links from a test e-commerce site with Python 3.

Prerequisites

If you haven’t done so already, install beautifulsoup4 and requests.

Start Scraping!

Check the collection in data.

>>> data
{‘MSI GL62VR 7RFX’: ‘/test-sites/e-commerce/allinone/product/326’,
‘Dell Vostro 15…’: ‘/test-sites/e-commerce/allinone/product/283’,
‘Dell Inspiron 17…’: ‘/test-sites/e-commerce/allinone/product/296’}

That’s it!

Here is the full snippet that you can copy and paste directly to your terminal, favorite text editor, or jupyter notebook.

Closing

Web scraping is great and can save you plenty of time when you want to quickly extract data from websites. The examples above are used for you to quickly get started. Of course there’s more to it than what I showed above e.g. (crawling, pagination, viewing the DOM, authentication, cookies, etc). This is only the tip of the iceberg 😉.

Thanks for reading — and please follow me here on Medium for more interesting software engineering articles!

The Startup

Medium's largest active publication, followed by +540K people. Follow to join our community.

Songtham Tung

Written by

Technical Product Director @ Geddit | B2B SaaS | SF ✈️ BKK

The Startup

Medium's largest active publication, followed by +540K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade