Skip to content

Instantly share code, notes, and snippets.

View EfrainOlivaresEv's full-sized avatar

EfrainOlivaresEv

View GitHub Profile
@EfrainOlivaresEv
EfrainOlivaresEv / table_writer.py
Created July 29, 2020 17:27 — forked from AO8/table_writer.py
Convert an HTML table into a CSV file with Python and BeautifulSoup.
# Adapted from example in "Web Scraping with Python, 2nd Edition" by Ran Mitchell.
import csv
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://en.wikipedia.org/wiki/"
"Comparison_of_text_editors")
soup = BeautifulSoup(html, "html.parser")
table = soup.findAll("table", {"class":"wikitable"})[0]