Search code examples
regexweb-scrapinggoogle-sheetsyoutubegoogle-query-language

Google Sheets IMPORTXML not working for YouTube URLs


I'm looking to extract the video title or video description from YouTube videos in Google Sheets. I have the URL and when I write the IMPORTXML formula, it keeps just showing me "Share your videos with friends, family, and the world" for the description and only "YouTube" if I change it to the title. Has something changed on YouTube's side?

Example: =IMPORTXML(F3,"//meta[@name='description']/@content")

Cell F3 contains value: https://www.youtube.com/watch?v=cwttM41xVBY

Output from formula: Share your videos with friends, family, and the world


Solution

  • try:

    =REGEXEXTRACT(QUERY(FLATTEN(IMPORTDATA(A1)), 
     "where Col1 starts with 'title:""'", 0), """(.*)""")
    

    enter image description here