2017-12-01 3 views
1

저는 이것이 꽤 간단한 문제라고 생각하지만, 저의 삶에 대해 알아 내지 못합니다. 나는 NBA 플레이어 성능에 담은 페이지에 도달하기 위해 노력하고 있어요 : (이상한 광고 시작 화면이 처음에 표시)를 두 번로드 할 필요버튼을 누르는 것을 자동화하려고 시도합니다.

https://www.bet365.com/#/AC/B18/C20559797/D47/E1/F43/P^47/Q^1/I

.

그래서 내 코드에 기본 페이지 (www.bet365.com)를로드하고 왼쪽에서 농구를 선택한 다음 페이지에서 "플레이어 실적"버튼을 찾으려고합니다. 이것은 내 어려움이 들어오는 곳입니다. 나는 CSS 선택기 또는 xpath를 사용하여 자동화 된 것을 클릭하려고했습니다. 그러나 내가 시도하는 것은 unclickable입니다. enter image description here

여기까지 내 코드가 있습니다. 프로그래밍 방식으로 NBA 플레이어 공연 페이지를 탐색하는 방법에 대한 조언이있는 사람이 있습니까?

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() 

이 그것을 만들 것을 확실하지, 내가 함께 왼쪽 줄에 농구를 탐색 할 수 있어요 : 내가 갈거야, 그래서 매일 페이지 변경의 URL이 코드를 찾을해야합니다 용이함. 기본적으로 내 목표는 해당 페이지를보고 NBA 플레이어 공연 링크 링크를 찾으려면 구문 분석 할 수 있도록하는 것입니다. 미리 감사드립니다. 나를 위해

답변

1

,이 코드는 윈도우 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); 

당신이 정말로보기에 요소를 스크롤 location_once_scrolled_into_view을 시도, 스크린을 통과해야하는 경우. 이 코드는 또한 나를 위해 일했습니다. (위의 추가 항목과 동일한 수입품) :

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() 
관련 문제