def fetch_soundcloud(user, album): url = soundcloud_url(user, album) output_file_name = "soundcloud_%s_%s.txt" % (user, album) driver = get_driver() driver.get(url) titles = fetch_streamer(driver, soundcloud_target_xpath) driver.quit() write_to_file(output_file_name, titles)
def fetch_youtube(album): url = youtube_url(album) driver = get_driver() driver.get(url) list_name = driver.find_element_by_id('title') output_file_name = "youtube_%s_%s.txt" % (list_name.text, album) titles = fetch_streamer(driver, youtube_target_xpath, 0) driver.quit() write_to_file(output_file_name, titles)
def choose_browser(): # Determine target browser if os.getenv('BROWSERSTACK_KEY') is None: print('Non-CI test') if FORCE_REMOTE_TESTING: # noinspection PyUnresolvedReferences from pytest.secret import secrets command_executor = secrets.command_executor web_driver = webdriver.Remote(command_executor=command_executor, desired_capabilities=desired_cap) web_driver.implicitly_wait(8) else: web_driver = get_driver() else: print('CI test') command_executor = os.getenv('BROWSERSTACK_KEY') web_driver = webdriver.Remote(command_executor=command_executor, desired_capabilities=desired_cap) return web_driver
__author__ = 'chance' from bs4 import BeautifulSoup import tools import time import push inst = push.Push() o_pts = new_o_pts = 0 sleep_interval = 2 url = "http://fantasy.espn.com/baseball/team?leagueId=162788&seasonId=2019&teamId=4&fromTeamId=4" driver = tools.get_driver() driver.get(url) time.sleep(7) while (1): print("Check: " + str(o_pts)) html = driver.page_source soup = BeautifulSoup(html, "lxml") my_data = soup.find_all("span", {"class": "team-record ttl"}) if len(my_data) > 0: new_o_pts = my_data[0].get_text()[:-4] if (new_o_pts != o_pts): chg = int(new_o_pts) - int(o_pts) print("Chg: " + str(chg)) print("New: " + str(new_o_pts)) inst.push_change(chg, "TOT PTS", str(new_o_pts)) o_pts = new_o_pts else:
f = open(outfile, "w") c = bdb.select("SELECT LeagueID, Name FROM Leagues where Active = 'True'") for t in c: league_dict[t[0]] = t[1] c = bdb.select( "SELECT * FROM Rosters where LeagueID in (SELECT LeagueID FROM Leagues where Active = 'True')" ) for t in c: old_rosters[t[0] + ':' + t[1]] = t[1] team_dict[t[1]] = t[2] c = bdb.select("SELECT * FROM Leagues where Active = 'True'") driver = tools.get_driver("headless") for t in c: url = "http://fantasy.espn.com/baseball/league/rosters?leagueId=" + str( t[0]) print(url) driver.get(url) time.sleep(20) html = driver.page_source soup = BeautifulSoup(html, "lxml") sections = soup.find_all("section") for section in sections: section_row = section.find_all('span') names = section.find_all('span', {'class': 'teamName truncate'})