Skip to content

Instantly share code, notes, and snippets.

@juanitobanca
Last active November 27, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanitobanca/f7eb6076f52c4632693b4fe60798c246 to your computer and use it in GitHub Desktop.
Save juanitobanca/f7eb6076f52c4632693b4fe60798c246 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.support.ui import Select, WebDriverWait
driver = webdriver.PhantomJS()
def obtenerRoster( teamId ):
tables = [ 'rosterPitchers', 'rosterCatchers', 'rosterInfielders', 'rosterOutfielders' ]
url = 'http://www.milb.com/roster/index.jsp?cid='+str(teamId)
driver.get( url )
for t in tables:
ti = driver.find_element_by_xpath('//*[@id="'+t+'"]/div/div[1]/table/tbody')
for ri in ti.find_elements_by_tag_name('tr'):
for ci in ri.find_elements_by_tag_name('td'):
print( ci.text )
obtenerRoster( 672 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment