-
-
Save gldomingo/ec1c9f3b6d8f229792594f958d940b50 to your computer and use it in GitHub Desktop.
web_scraping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### GETS LIST AND SEPARATES PRESIDENTS FROM VPs | |
p_td = p.find_all('td') | |
pres = [] | |
vp = [] | |
for tag in p_td: | |
try: | |
int(tag.get_text()[0]) | |
pres.append(tag.get_text()) | |
except (ValueError): | |
vp.append(tag.get_text()) | |
### RETRIEVES LIST OF P AND VP BY PARTY | |
party = p2.find_all('div',{'class':"col-xs-3"}) | |
### RETURNS LIST OF PRESIDENTS AND VPs BY PARTY | |
for i in range(len(party)): | |
if i == 0: | |
rep = party[i].get_text().split('\n') | |
elif i == 1: | |
dem = party[i].get_text().split('\n') | |
elif i == 2: | |
other = party[i].get_text().split('\n') | |
else: | |
etc = party[i].get_text().split('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment