Created
March 3, 2025 15:26
-
-
Save LucianBuzzo/957e4dcb9cccaf5512d1d39e56953cb0 to your computer and use it in GitHub Desktop.
Genius song lyrics scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { test } from "@playwright/test"; | |
| const userAgent = | |
| "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"; | |
| test.use({ | |
| userAgent, | |
| }); | |
| test("Genius", async ({ page }) => { | |
| const searchQuery = "under pressure"; | |
| const url = `https://genius.com/search?q=${encodeURIComponent(searchQuery)}`; | |
| await page.goto(url); | |
| await page.locator('div[aria-label="Privacy"]').getByText("I accept").click(); | |
| await page.locator(".mini_card").first().click(); | |
| await page.locator("#lyrics-root").waitFor({ state: "visible" }); | |
| const lyrics = await page.locator("#lyrics-root").innerText(); | |
| console.log(lyrics); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment