Intro To Web Scraping With Python – Download

Affiliate Program Get Money from your Website

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: