有没有一种方法可以使用puppeteer无限期滚动Spotify?

时间:2020-08-10 23:35:23

标签: node.js scroll puppeteer spotify

我是node.js和puppeteer的新手,我试图找到一种滚动到播放列表末尾的方式来抓取歌曲名称和艺术家。我尝试过此问题的最佳答案: Puppeteer - scroll down until you can't anymore

适用于Google之类的网站,但对Spotify无效。 我已经尝试过像window.scrollBy()这样的代码,但是我有一种直觉,认为滚动条是用javascript创建的,我想不出一种显示更多播放列表的方法。

这是一个延迟加载https://open.spotify.com/playlist/37i9dQZF1DWWQRwui0ExPn

的示例播放列表

1 个答案:

答案 0 :(得分:0)

我也是Node的新手,但我认为使用mouse.move应该会得到一些东西

mouse wheel options - puppeteer

(代码来自文档)

await page.goto('https://mdn.mozillademos.org/en-US/docs/Web/API/Element/wheel_event$samples/Scaling_an_element_via_the_wheel?revision=1587366');

const elem = await page.$('div');
const boundingBox = await elem.boundingBox();
await page.mouse.move(
  boundingBox.x + boundingBox.width / 2,
  boundingBox.y + boundingBox.height / 2
);

await page.mouse.wheel({ deltaY: -100 })

从未使用过,但绝对值得一试。