I'm trying to scrape from multiple Ballotpedia pages with Python and put this info into a csv, but am only getting the results for the last element of the list. Here is my code:
import pandas as pd
list = ['https://ballotpedia.org/Alaska_Supreme_Court',
'https://ballotpedia.org/Utah_Supreme_Court']
for page in list:
frame = pd.read_html(page,attrs={"class":"wikitable
sortable jquery-tablesorter"})[0]
frame.drop("Appointed By", axis=1, inplace=True)
frame.to_csv("18-TEST.csv", index=False)
I've been playing around with adding and deleting parts of the last line of the code but the issue remains. The first element of the list must be getting added to the csv but them gets replaced by the second element. How can I get both to show up on the csv at the same time? Thank you very much!