Googles IMPORTXML returns "Imported content is empty" error

Viewed 8688

I'm trying to get the value of the link of the first youtube video that appears after a youtube search and write it into my google spreadsheet. In order to do this, I am using the in-built IMPORTXML(url, xml_query) function. I have copied the full XPath using google chrome and received the following:

/html/body/ytd-app/div/ytd-page-manager/ytd-search/div[1]/ytd-two-column-search-results-renderer/div/ytd-section-list-renderer/div[2]/ytd-item-section-renderer/div[3]/ytd-video-renderer[1]/div[1]/ytd-thumbnail/a/@href

I have placed the following code in a spreadsheet cell:

=IMPORTXML("https://www.youtube.com/results?search_query=ajfdkla+trailer", "/html/body/ytd-app/div/ytd-page-manager/ytd-search/div[1]/ytd-two-column-search-results-renderer/div/ytd-section-list-renderer/div[2]/ytd-item-section-renderer/div[3]/ytd-video-renderer[1]/div[1]/ytd-thumbnail/a/@href")

and received the following error:

Imported content is empty.

How can I write the URL of the first youtube video following a youtube search into my spreadsheet cell.

1 Answers
Related