A simple script to scrape the first page of Quotes to Scrape website.
Set up a Node.js project with the necessary dependencies (express, axios and JSDOM).
- Write a script using axios to fetch the contents of the Quotes to Scrape first page.
- Use JSDOM to parse the HTML content and extract the following details for each product listing on the first page:
- Quote text
- Author
- Tags
- Create an endpoint /api/scrape and returns the extracted data in JSON format. Develop a simple webpage: Style the webpage to be user-friendly and presentable.
Ensure to handle errors gracefully both on the backend and frontend. The cleaner and more functional the code is, the better.
- Quotes
- (.quote)
- Quote text
- (.text)
- Author
- (.author)
- Tags
- (.tag)
Endpoint /api/scrape
[
{
"quote": "“The world as we have created it is a process of our thinking. It cannot be changed without changing our thinking.”",
"author": "Albert Einstein",
"tags": [
"change",
"deep-thoughts",
"thinking",
"world"
]
},
]
- Backend (Node.Js v20.11.1)
- Typescript
- Axios
- Express
- JSDOM
- Linkedin - Nícolas Samuel