Skip to content

Instantly share code, notes, and snippets.

@ericabell
Created May 4, 2017 15:06
Show Gist options
  • Save ericabell/9c4c52ab51a801303e49d0348b47289f to your computer and use it in GitHub Desktop.
Save ericabell/9c4c52ab51a801303e49d0348b47289f to your computer and use it in GitHub Desktop.
pooya
import pandas
import requests
from bs4 import BeautifulSoup
page = requests.get('http://www.politico.com/2012-election/results/president/wisconsin/')
soup = BeautifulSoup(page.text, "html.parser")
for body in soup("tbody"):
body.unwrap()
tables = pandas.read_html(str(soup), flavor="bs4")
pandas.set_option('display.max_rows', len(tables[1]))
print (tables[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment