-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
68 lines (50 loc) · 1.76 KB
/
index.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const axios = require('axios').default
const express = require('express')
const cheerio = require('cheerio')
var html = `<table class="table">
<thead>
<tr>
<th scope="col">*</th>
<th scope="col">Sehir adi</th>
<th scope="col">Iftar vakti</th>
<th scope="col">Yatsi vakti</th>
</tr>
</thead>
<tbody>
`
const app = express()
var veriler = ""
app.get('/', (req, res) => {
axios.get('https://www.haberturk.com/namaz-vakitleri').then(response => {
const $ = cheerio.load(response.data)
const iftarvakitleri = []
$('.w-full > tbody').each(function () {
$(this).find('tr').each(function () {
const iftarvakti = {
sehir: $(this).find('td:nth-child(1)').text(),
imsak: $(this).find('td:nth-child(2)').text(),
gunes: $(this).find('td:nth-child(3)').text(),
ogle: $(this).find('td:nth-child(4)').text(),
ikindi: $(this).find('td:nth-child(5)').text(),
aksam: $(this).find('td:nth-child(6)').text(),
yatsi: $(this).find('td:nth-child(7)').text()
}
veriler+=`
<tr>
<th scope="row">#</th>
<td>${$(this).find('td:nth-child(1)').text()}</td>
<td>${$(this).find('td:nth-child(6)').text()}</td>
<td>${$(this).find('td:nth-child(7)').text()}</td>
</tr>
`
})
res.send(html+veriler+`</tbody></table>`)
//iftarvakitleri.push(iftarvakti)
})
res.json(iftarvakitleri)
})
}
)
app.listen(3000, () => {
console.log('listening on port 3000')
})