Reputation: 43
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.
Upvotes: 3
Views: 18518
Reputation: 38200
IMPORTXML can't see the DOM shown by Chrome Developer Tools on the Elements tab, it can only see the source code returned by the URL, so instead, you should look at the Sources tab or easier, right click the page and select View page source.
Resources
Upvotes: 8