-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 1.04 KB
/
index.js
File metadata and controls
36 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const axios = require("axios");
const cheerio = require("cheerio");
const express = require("express");
const PORT = process.env.PORT || 3000;
const app = express();
app.listen(PORT, () => console.log(`server running o PORT ${PORT}`));
const url = "https://www.nefisyemektarifleri.com/kategori/tarifler/aperatifler-tarifler/";
axios(url)
.then(response => {
const html = response.data;
const $ = cheerio.load(html);
const articles = [];
$('.col-md-4.col-sm-6.col-xs-12', html).each(function () {
const image = $(this).find('.wp-post-image').attr('data-lazy-src');
const title = $(this).find('.recipe-info .title').text();
const url = $(this).find('a').attr('href');
const description = $(this).find('.recipe-elements').text();
const author = $(this).find('.recipe-owner').attr('title') || "";
articles.push({
image,
title,
description,
url,
author
});
});
app.get('/', (req, res) => {
res.send(articles);
});
}).catch(err => console.log(err));