Skip to content

Instantly share code, notes, and snippets.

@brettclare
Created April 29, 2016 23:47
Show Gist options
  • Save brettclare/35d3bb9489532fbd0e84feee91ffaa09 to your computer and use it in GitHub Desktop.
Save brettclare/35d3bb9489532fbd0e84feee91ffaa09 to your computer and use it in GitHub Desktop.
Enter file contents hereimport csv
import requests
from bs4 import BeautifulSoup
url = 'http://log.concept2.com/rankings/2016/rower/5000?age=50-59&weight=H&gender=M&status=verified'
response = requests.get(url)
html = response.content
soup=BeautifulSoup(html)
table=soup.find('tbody')
list_of_rows=[]
for row in table.findAll('tr'):
list_of_cells=[]
for cell in row.findAll('td'):
text=cell.text.replace(' ','')
list_of_cells.append(text)
list_of_rows.append(list_of_cells)
outfile = open("./5000erg50Heavy.csv","w")
writer = csv.writer(outfile)
writer.writerow(["Position","Name","Age","Location","Country","Club","Time","Type","Verified"])
writer.writerows(list_of_rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment