Using ImportXML to grab view count given specific tiktok video link?

Viewed 226

I am looking to use ImportXML to grab a specific video's view count given the video link.

So far I have =IMPORTXML("https://www.tiktok.com/@indiesintrouble", "//a/@href[contains(., '7086171822655327530')]") but I am having trouble then grabbing the view count from there.

If it helps, I have been grabbing view counts of all videos (for another purpose) using IMPORTXML("https://www.tiktok.com/@indiesintrouble","//strong[@data-e2e='like-count']","US")

And here is the Inspect Element view:

enter image description here

Appreciate any help I can get!

1 Answers

After some trial and error, I came up with the following which appears to work... but I definitely don't trust myself:

//a[contains(@href, 'https://www.tiktok.com/@indiesintrouble/video/7086171822655327530')]//strong[@data-e2e='video-views']

I would still love to see other solutions as perhaps that will help me better understand everything and I could replace my existing one with it.

Thanks in advance!

enter image description here

Related