2

I'm trying to populate a Google Sheet with a table that contains the 10 most recent YouTube videos from a channel along with the video title, video URL, date, description, and thumbnail image.

When I try to use IMPORTXML on the Google Sheet, I get an error that "Imported content is empty":

screenshot of Google Sheets error

Here's the formula in the field:

=IMPORTXML("https://www.youtube.com/feeds/videos.xml?channel_id=UCmGSJVG3mCRXVOP4yZrU1Dw","/feed/entry[1]/media:group/media:thumbnail/@url")

I've tried testing the xpath on a few online testers, and they seem to return the URL, but it doesn't work in Google Sheets.

vincentpv
  • 23
  • 2
  • https://stackoverflow.com/a/55064665/5632629 – player0 Mar 22 '22 at 02:58
  • Thanks for that link. It looks like that page is scraping the page for individual YouTube videos. Each channel has an XML feed that has all of the videos from a channel (ie. https://www.youtube.com/feeds/videos.xml?channel_id=[INSERT CHANNEL ID]), so I'm trying to pull the video thumbnail off this XML feed. – vincentpv Mar 22 '22 at 14:27

1 Answers1

1

Well that is a problem with namespaces. See i.e. this good answer

In your case the XPath could be:

/*[local-name()='feed']/*[local-name()='entry'][1]/*[local-name()='group']/*[local-name()='thumbnail']/@url
Siebe Jongebloed
  • 3,906
  • 2
  • 14
  • 19