# Genius Lyric Scraper (`headlessagent/genius-lyric-scraper`)

This Apify Actor extracts song lyrics and metadata from Genius.com based on provided URLs. It's designed for efficient data collection of specific song information.

- **URL**: https://beta-securitybyobscurity.apify.com/headlessagent/genius-lyric-scraper.md
- **Developed by:** [Headless Agent](https://beta-securitybyobscurity.apify.com/headlessagent) (community)
- **Categories:** Automation, Other, Developer tools
- **Stats:** 5 total users, 4 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.
You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

# README

## Genius Lyrics Scraper

This Apify Actor extracts song lyrics and metadata from Genius.com based on provided URLs. It's designed for efficient data collection of specific song information.

### Features

- Extracts lyrics, song title, artist, and URL from a specified Genius.com song page.
- Outputs structured JSON for easy integration and analysis.

### Input

The Actor expects a JSON input with the following fields:

```json
{
  "startUrls": [
    {
      "url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics"
    }
  ],
  "maxRequestsPerCrawl": 100,
  "useProxy": false
}
```

- **`startUrls`** (array of objects, required):
  A list of URLs to start scraping. Each object should contain a `url` property pointing to a Genius song page.
  Example: `[{"url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics"}]`

- **`maxRequestsPerCrawl`** (integer, optional):
  Maximum number of requests that can be made by this crawler.
  Default: `100`

- **`useProxy`** (boolean, optional):
  Whether to use Apify Proxy for crawling.
  Default: `false`

### Output

For every song page successfully scraped, the output dataset (`genius-lyrics`) will contain an object with detailed fields.

**Example Song Output:**

```json
{
	"id": 10620191,
	"url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics",
	"lyric": "[Verse 1]\nKhalil, my brother, I'm so happy I got to know you\nIt's an honor to say that I was once your friend\nI had met you through Javi and through TJ\nWhen they brought you to my apartment in Tampa\n\n[Verse 2]\nWe were playing drinking games on the coffee table\nAnd you threw up 'cause you weren't used to the way it felt\nYou were embarrassed, and I told you that it was okay\nAnd at least it didn't get on the wall and then we laughed\nBut who would've thought that we would get to meet that way?\nAnd that slowly would get to see each other much more\nAnd I would drive about twenty minutes each way\nJust to pick you up and have you in my housе\nYou were sleeping on my green little Ikеa futon\nAbout twice to maybe five times a week and I didn't mind\nFor I had loved you for your kindness and genuine compassion\nFor your smile and your dumb little jokes and the way you were there\nAnd when I'd cry about the past, like how fucked up I got from Graham\nYou would get me and help me to move on to what's next\nAnd when you were down, I'd be there always to hear you out\nWith my open arms, maybe some food, while you let it out, oh\n\n[Verse 3]\nI can't forget you even if I tried, even if I'm tired\nAnd I fade out, I wish I did more\nWish I could've seen all the fucking signs when I left town\nI won't forget you even if I lose, even if I can't remember myself\nI wish I knew more, wish you could've stayed with me to help you out\n\n[Outro]\nI will honor you the only way that I know how\nBy just doing the things that you had known me for\nKhalil Mon Frere, I will miss you for all of my life\nAnd I'll carry this guilt until the day I die",
	"media": [
		{
			"url": "https://soundcloud.com/mixedmatches-1/khalil-pt-1?in=mixedmatches-1/sets/were-here-now-and-thats-all&si=249706daab13487b87553f7c254d8220&utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing",
			"type": "audio",
			"provider": "soundcloud"
		},
		{
			"url": "https://www.youtube.com/watch?v=Y7bZME5oy30",
			"type": "video",
			"provider": "youtube"
		}
	],
	"artist": {
		"id": 1215474,
		"slug": "Mixed-matches",
		"name": "mixed matches",
		"verified": false,
		"image_url": "https://images.genius.com/704bc28ec95e44cd0190e2efa152759e.640x640x1.jpg",
		"header_image_url": "https://images.genius.com/2d6f9a1a6654cfe55054d461fbe3bf8c.500x500x48.gif"
	},
	"release_date": "July 7, 2024"
}
```

# Actor input Schema

## `startUrls` (type: `array`):

URLs to start with.

## `maxRequestsPerCrawl` (type: `integer`):

Maximum number of requests that can be made by this crawler.

## `useProxy` (type: `boolean`):

Whether to use Apify Proxy for crawling.

## `rawData` (type: `boolean`):

Raw data to be processed.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics"
    }
  ],
  "maxRequestsPerCrawl": 100,
  "useProxy": false,
  "rawData": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics"
        }
    ],
    "useProxy": false,
    "rawData": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("headlessagent/genius-lyric-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": [{ "url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics" }],
    "useProxy": False,
    "rawData": False,
}

# Run the Actor and wait for it to finish
run = client.actor("headlessagent/genius-lyric-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://genius.com/Mixed-matches-khalil-pt1-lyrics"
    }
  ],
  "useProxy": false,
  "rawData": false
}' |
apify call headlessagent/genius-lyric-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=headlessagent/genius-lyric-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Genius Lyric Scraper",
        "description": "This Apify Actor extracts song lyrics and metadata from Genius.com based on provided URLs. It's designed for efficient data collection of specific song information.",
        "version": "0.0",
        "x-build-id": "xpv83hOQ0ceoqORnW"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/headlessagent~genius-lyric-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-headlessagent-genius-lyric-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/headlessagent~genius-lyric-scraper/runs": {
            "post": {
                "operationId": "runs-sync-headlessagent-genius-lyric-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/headlessagent~genius-lyric-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-headlessagent-genius-lyric-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "URLs to start with.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxRequestsPerCrawl": {
                        "title": "Max Requests per Crawl",
                        "type": "integer",
                        "description": "Maximum number of requests that can be made by this crawler.",
                        "default": 100
                    },
                    "useProxy": {
                        "title": "Use Proxy",
                        "type": "boolean",
                        "description": "Whether to use Apify Proxy for crawling.",
                        "default": false
                    },
                    "rawData": {
                        "title": "Raw Data",
                        "type": "boolean",
                        "description": "Raw data to be processed.",
                        "default": false
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
