I'm trying to scrape player data from college football roster sites. I am primarily interested in getting the player image, weight, and name. I have already been able to extract the weight and name but am struggling on extracting the image using selenium. This is my code so far.
driver = webdriver.Chrome("C:/Users/<my_user>/Downloads/chromedriver.exe")
driver.get(school["url"])
all_names = driver.find_elements(by=By.CLASS_NAME, value='sidearm-roster-player-name')
all_weights = driver.find_elements(by=By.CLASS_NAME, value='sidearm-roster-player-weight')
all_imgs = driver.find_elements(by=By.CLASS_NAME, value='sidearm-roster-player-image')
This is an example of what would be passed in as school[url]
. Many colleges use this format.
https://rolltide.com/sports/football/roster
Each player on this site has the following html element.
<div class="sidearm-roster-player-image column">
<a data-bind="click: function() { return true; }, clickBubble: false" href="/sports/football/roster/jeremiah-alexander/8141" aria-label="Jeremiah Alexander - View Full Bio" title="View Full Bio">
<img class=" lazyloaded" data-src="https://d1a8hwz3c6qyrc.cloudfront.net/images/2022/3/1/Alexander_Jeremiah.jpg?width=80" alt="Jeremiah Alexander" src="https://d1a8hwz3c6qyrc.cloudfront.net/images/2022/3/1/Alexander_Jeremiah.jpg?width=80">
</a>
</div>
The issue I am running into is that each webElement
in all_imgs
does not seem to have an attribute such called 'img' or any attribute I can see that represents the image link located within the element. How can I get the link of all the images of the players on this page?