Intro To Web Scraping With Python – Download

In this video we will look at web scraping using Python and the BeautifulSoup library. This is an introductory level tutorial. All beginners welcome

Final Code Gist:

import requests
from bs4 import BeautifulSoup
from csv import writer
response = requests.get('')
soup = BeautifulSoup(response.text, 'html.parser')
posts = soup.find_all(class_='post-preview')
with open('posts.csv', 'w') as csv_file:
csv_writer = writer(csv_file)
headers = ['Title', 'Link', 'Date']
for post in posts:
title = post.find(class_='post-title').get_text().replace('\n', '')
link = post.find('a')['href']
date ='.post-date')[0].get_text()
csv_writer.writerow([title, link, date])
view raw
hosted with ❤ by GitHub

Become a Patron: Show support & get perks!

Website & Udemy Courses

Follow Traversy Media:


Do you love us?, Please donate to us ,thank you. BTC 38WPVc3xMYmoMp1GcnpDXd1fEzbfgujsCB Etherum 0x6c11844FD079b2490CDd44039e1C2f0940d098dc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.