I'm trying to write a script in Python to grab all of the rosters in my fantasy football league, but you have to login to ESPN first. The code I have is below. It looks like it's working when it runs -- i.e., I see the login page come up, I see it login, and the page closes. Then when I print the soup I don't see any team rosters. I saved the soup output as an html file to see what it is and it's just the page redirecting me to login again. Do I load the page through BS4 before I try to login?
import time
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import urllib.request as urllib2
from bs4 import BeautifulSoup
driver = webdriver.Chrome()
driver.get("http://games.espn.go.com/ffl/signin")
#implement wait it is mandatory in this case
WebDriverWait(driver,1000).until(EC.presence_of_all_elements_located((By.XPATH,"(//iframe)")))
frms = driver.find_elements_by_xpath("(//iframe)")
driver.switch_to_frame(frms[2])
time.sleep(2)
driver.find_element_by_xpath("(//input)[1]").send_keys("userrname")
driver.find_element_by_xpath("(//input)[2]").send_keys("password")
driver.find_element_by_xpath("//button").click()
driver.switch_to_default_content()
time.sleep(4)
#driver.close()
# specify the url
roster_page = 'http://games.espn.com/ffl/leaguerosters?leagueId=11111'
# query the website and return the html to the variable 'page'
page = urllib2.urlopen(roster_page)
# parse the html using beautiful soup and store in variable `soup`
soup = BeautifulSoup(page, 'html.parser')