Reputation: 151
I think this is a pretty simple issue, however I can't figure it out for the life of me. I am trying to reach the NBA Player Performance Prop Page:
https://www.bet365.com/#/AC/B18/C20559797/D47/E1/F43/P^47/Q^1/I
which is required to be loaded twice (weird ad splash screen shown at first).
So I have my code load the main page (www.bet365.com), and then select basketball on the left, then I attempt to find the "Player Performances" button on the page. This is where my difficulty's come in. I have been trying to click it automated by using the css selector or the xpath. However anything I try is unclickable.
Here is my code so far, does anyone have any advice as to how to programatically navigate to the NBA Player Performances page. The url on the page changes on a daily basis so I am going to be required to find it by code:
url = "https://www.bet365.com/"
driver = webdriver.Chrome('./chromedriver.exe ')
driver.get(url);
print("Waiting To Ensure Data Load 1 of 2")
time.sleep(5) # Let the user actually see something!
driver.get(url);
print("Waiting To Ensure Data Load 2 of 2")
time.sleep(5)
print("Naviagating to BasketballSection Section")
driver.find_element_by_css_selector("body > div:nth-child(1) > div > div.wc-PageView > div.wc-PageView_Main.wc-HomePage_PageViewMain > div > div.wc-HomePage_ClassificationWrapper.wc-CommonElementStyle_WebNav > div > div > div:nth-child(7)").click();
time.sleep(5)
urltwo = "body > div:nth-child(1) > div > div.wc-PageView > div.wc-PageView_Main > div > div.wc-CommonElementStyle_PrematchCenter.wc-SplashPage_CenterColumn > div.sm-SplashModule > div:nth-child(1) > div:nth-child(3) > div.sm-MarketGroup_Open > div > div.sm-MarketContainer.sm-MarketContainer_NumColumns1.sm-Market_Open > div > div"
submit = driver.find_element_by_css_selector(urltwo)
submit.click()
Not sure what to make of it, I am able to navigate to Basketball on the left bar with ease. Basically my goal is to be able to see that page, and parse to find the link to the NBA Player Performances link; Thanks in advance.
Upvotes: 1
Views: 126
Reputation: 2690
For me, this code works in Chrome on Windows 10:
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
options = Options()
options.add_argument('--disable-infobars')
driver = webdriver.Chrome(chrome_options=options)
url = "https://www.bet365.com/#/AC/B18/C20559797/D47/E1/F43/P^47/Q^1/I"
# First get only navigates to https://www.bet365.com
driver.get(url);
# Second one gets you to the full URL path.
driver.get(url);
If you really need to traverse the screens, try location_once_scrolled_into_view
to scroll the element into view. This code also worked for me (same imports as above with these additional):
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "https://www.bet365.com/#/AS/B18/"
driver.get(url);
driver.get(url);
player_perf_xpath = "/html/body/div[1]/div/div[2]/div[1]/div/div[2]/div[2]/div[1]/div[3]/div[2]/div/div[2]/div/div"
element = driver.find_element_by_xpath(player_perf_xpath)
# Scroll the screen so the element is visible and can be clicked
element.location_once_scrolled_into_view
element.click()
Upvotes: 1