I am new to web scraping and could use some help. I would like to scrape the NBA's starting lineup, the teams and the player's positions using Xpath. I only starting on the names because I was running into an issue.
Here is my code so far:
from urllib.request import urlopen
from lxml.html import fromstring
url = "https://www.lineups.com/nba/lineups"
content = str(urlopen(url).read())
comment = content.replace("-->","").replace("<!--","")
tree = fromstring(comment)
for nba, bball_row in enumerate(tree.xpath('//tr[contains(@class,"t-content")]')):
names = bball_row.xpath('.//span[@_ngcontent-c5="long-player-name"]/text()')[0]
print(names)
It looks like the program runs without error but the names do not print. Any tips on how to parse using Xpath more efficiently would be greatly appreciated. I tried messing with Xpath helper and Xpath Finder. Maybe there are some tricks on there in order to make the process easier. Thanks in advance for your time and effort!