This project is developed in Node.js using TypeScript and follows a serverless architecture. It's responsible for extracting relevant data from a given URL, such as the title, description, main image, and domain.
To install and run this project locally, follow these steps:
- Clone this repository to your local machine.
- Ensure you have Node.js and npm installed.
- Install dependencies
You can utilize the function to extract data from a provided URL by sending a GET request to the function URL with the url
parameter containing the URL you wish to process. Below is an example of how to do this:
GET : https://example-domain/.netlify/functions/getUrlData?url=https://www.youtube.com/watch?v=4xDzrJKXOOY
The function will respond with a JSON object containing the extracted information from the provided URL:
{
"title": "synthwave radio ๐ - beats to chill/game to - YouTube",
"description": "๐ผ | Listen on Spotify, Apple music and moreโ https://fanlink.tv/ChillSynthwave๐ถ | Subscribe to this channel for more synthwave musicโ https://bit.ly/synt...",
"source": "https://www.youtube.com/watch?v=4xDzrJKXOOY",
"img": "https://i.ytimg.com/vi/4xDzrJKXOOY/maxresdefault_live.jpg",
"domain": "https://www.youtube.com"
}
- @netlify/functions
npm install @netlify/functions
axios
npm installl axios
cheerio
npm install cheerio
- typescript
- @types/node
- rimraf
- ts-node-dev
- commit-and-tag-version
npm install -D typescript @types/node ts-node-dev rimraf commit-and-tag-version
- netlify/cli
npm install -D netlify-cli
- @types/cheerio
npm install --save-dev @types/cheerio
npm run tsc:init