0
votes

This response.xpath statement is returning an empty array and I'm not too sure why. I'm trying to retrieve @alt result. This is what I have tried...

response.xpath('//*[@id="all_teams_war_images"]/div/a/img/@alt').extract()

Oddly enough this returns all elements within that div

response.xpath('//*[@id="all_teams_war_images"]').extract()

this is the website I am trying to scrape https://baseball-reference.com/teams/BOS/2018.shtml

1
I believe '//*[@id="all_teams_war_images"]/div/a/img/@alt' is looking only in the first child <div> underneath the element with that id, which does not contain any <a> elements. How did you get that xpath? Did you type it by hand? - John Gordon

1 Answers

1
votes

The content you're trying to parse is hided in HTML comment section. See this answer for details