Currently using document.querySelector with puppeteer to retrieve the video links from a Tiktok account's HTML code and am having issues retrieving exactly what I need
With this code:
const grabURLs = await page.evaluate(() => {
const pgTag = document.querySelector('.tiktok-1qb12g8-DivThreeColumnContainer.eegew6e2 div div div div div')
return pgTag.innerHTML;
})
console.log(grabURLs)
I receive not only the href that I need but also all of the child elements below that, how do I limit it so the only innerHTML I receive is the first child?
<><div class="tiktok-x6y88p-DivItemContainerV2 e19c29qe7">
<div data-e2e="user-post-item" class="tiktok-x6f6za-DivContainer-StyledDivContainerV2 e1gitlwo0">
<div style="padding-top: 132.653%;" />
<div class="tiktok-yz6ijl-DivWrapper e1cg0wnj1">
<a href="https://www.tiktok.com/@nottooshabbycakes/video/7063163560238599430">
<canvas width="75.38461538461539" height="100" class="tiktok-1yvkaiq-CanvasPlaceholder e19c29qe2"></canvas>
<div class="tiktok-1wa52dp-DivPlayerContainer e19c29qe4">
<div mode="1" class="tiktok-1jxhpnd-DivContainer e1yey0rl0">
<img mode="1" src="https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/8ba10e1631d14b75b0bad5988c971113?x-expires=1663250400&x-signature=%2F3yL04w%2FMNG9AF1TYWI51Sq41jU%3D" alt=" #corememory" loading="lazy" class="tiktok-1itcwxg-ImgPoster e1yey0rl1"></></div>
<div class="tiktok-11u47i-DivCardFooter e148ts220">
<svg class="like-icon tiktok-h342g4-StyledPlay e148ts225" width="18" height="18" viewBox="0 0 48 48" fill="#fff" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 10.554V37.4459L38.1463 24L16 10.554ZM12 8.77702C12 6.43812 14.5577 4.99881 16.5569 6.21266L41.6301 21.4356C43.5542 22.6038 43.5542 25.3962 41.6301 26.5644L16.5569 41.7873C14.5577 43.0012 12 41.5619 12 39.223V8.77702Z"></path></svg>
<strong data-e2e="video-views" class="video-count tiktok-1p23b18-StrongVideoCount e148ts222">57</strong>
Here is the HTML and I am trying to extract just the href but it's logging a with all elements below it
Any help would be greatly appreciated thank you!