No Data Returned When Using Function To Get Data From Site Using Selenium
I have a list with a few boxers. I have created a function that will use selenium to open a particular web page, and then type in the name of a given boxer in my list on an autocom
Solution 1:
wait.until(EC.visibility_of_element_located((By.ID,'s2id_autogen1'))).send_keys('Deontay Wilder')
Is it intentional 'Deontay Wilder' hardcoded in your function definition?
Edit
till now I can only say you to change you code with this line (added another row in class, without it fighters returned empty list
fighters = cdriver.find_elements_by_xpath("//div[@class='row row-bottom-margin-5']/div[2]")
I can print fighter.text values in console, but I can't append nothing to fight_data, neither an hardcoded string. I don't understand why...
Edit2
boxer_list = ['Deontay Wilder','Tyson Fury','Andy Ruiz']
defget_boxers(boxers):
page_link = 'http://beta.compuboxdata.com/fighter'
chromedriver = 'C:\\Users\\User\\Downloads\\chromedriver'
cdriver = webdriver.Chrome(chromedriver)
cdriver.maximize_window()
cdriver.get(page_link)
wait = WebDriverWait(cdriver,10)
wait.until(EC.visibility_of_element_located((By.ID,'s2id_autogen1'))).send_keys(str(boxers))
wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'select2-result-label'))).click()
whileTrue:
try:
element = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'view_more')))
element.click()
except :
break
fighters = cdriver.find_elements_by_xpath("//div[@class='row row-bottom-margin-5']/div[2]")
cols = ['fighters', 'stats']
fight_data = pd.DataFrame(columns = cols)
for fighter in fighters:
fight_data=fight_data.append({'fighters':fighter.text},ignore_index=True)
cdriver.find_element_by_xpath("//a[contains(@onclick,'get_fight_report')]").click()
punches = cdriver.find_elements_by_xpath("//div[@class='modal-content']")
for punch in punches:
fight_data=fight_data.append({'stats':punch.text},ignore_index=True)
cdriver.refresh()
return fight_data
I don't know how you want to collect stats. it's pretty a giant form and so punch.text return empty list. The first part in the meanwhile is solved
Post a Comment for "No Data Returned When Using Function To Get Data From Site Using Selenium"