-
Notifications
You must be signed in to change notification settings - Fork 0
/
fantasyLineup.py
69 lines (53 loc) · 2.29 KB
/
fantasyLineup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from selenium import webdriver
import time
import selenium.webdriver.chrome.service as service
import selenium.webdriver.common.keys as keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import numpy as np
from team import Team
from roster import Slot
from player import Player
from roster import Roster
class Account:
def __init__(self):
self.driver = webdriver.Chrome()
self.ESPN_USERNAME = "trojansrck123"
self.ESPN_PASSWORD = "netLife051"
self.teams = []
self.driver.get("http://www.espn.com/fantasy/")
def login(self):
logIn = self.driver.find_element_by_class_name("user")
button = self.driver.find_element_by_xpath("//*[@class='account-management']/li[position()=4]")
ActionChains(self.driver).move_to_element(logIn).click().pause(1).perform()
ActionChains(self.driver).move_to_element(button).click().pause(1).perform()
ActionChains(self.driver).send_keys(self.ESPN_USERNAME).perform()
ActionChains(self.driver).send_keys(Keys.TAB).perform()
ActionChains(self.driver).send_keys(self.ESPN_PASSWORD).perform()
ActionChains(self.driver).send_keys(Keys.ENTER).pause(2).perform()
def getTeams(self):
fantasy = self.driver.find_element_by_class_name("fantasy")
ActionChains(self.driver).move_to_element(fantasy).click().perform()
try:
teamsList = fantasy.find_elements_by_class_name("team")
for index, team in enumerate(teamsList):
url = team.find_element_by_tag_name("a").get_attribute("href")
self.teams.append(Team(url))
except:
print("No Teams Have Been Found")
def close(self):
self.driver.close()
def setBasketballLineup(self, index, research=True):
team = self.teams[index]
if research:
team.url = team.url + "&view=research&scoringPeriodId=104"
self.driver.get(team.url)
teamRoster = Roster(self.driver)
teamRoster.move("Elfrid Payton","UTIL_3")
teamRoster.move("Serge Ibaka","F")
time.sleep(3)
myA = Account()
myA.login()
myA.getTeams()
myA.setBasketballLineup(3)
myA.close()