-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
72 lines (65 loc) · 2.44 KB
/
app.js
File metadata and controls
72 lines (65 loc) · 2.44 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
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
69
70
71
72
const request = require("request");
const cheerio = require("cheerio");
const express = require("express")
const app = express()
app.get("/nobetci/:il" , async (req , res) => {
let eczaneler = []
let options = {
url: 'https://www.eczaneler.gen.tr/nobetci-' + req.params.il,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'
}
}
request(options, (error, resp, body) => {
if (!error && resp.statusCode == 200) {
const $ = cheerio.load(body)
$("#nav-bugun .row").each((i, el) => {
const name = $(el).find(".isim").text()
const address = $(el).find(".text-capitalize").text()
const subAddress = $(el).find(".text-secondary").text()
const timing = $(el).find(".text-success").text()
const phoneNumber = $(el).find(".py-lg-2").text()
eczaneler.push( {
name,
address,
subAddress,
timing,
phoneNumber
})
})
res.send(eczaneler)
}
})
})
app.get("/nobetci/:il/:ilce" , async (req , res) => {
let eczaneler = []
let options = {
url: 'https://www.eczaneler.gen.tr/nobetci-' + req.params.il + "-" + req.params.ilce,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'
}
}
request(options, (error, resp, body) => {
if (!error && resp.statusCode == 200) {
const $ = cheerio.load(body)
$("#nav-bugun .row").each((i, el) => {
const name = $(el).find(".isim").text()
const address = $(el).find(".text-capitalize").text()
const subAddress = $(el).find(".text-secondary").text()
const timing = $(el).find(".text-success").text()
const phoneNumber = $(el).find(".py-lg-2").text()
eczaneler.push( {
name,
address,
subAddress,
timing,
phoneNumber
})
})
}
res.send(eczaneler)
})
})
app.listen(3000 , () => {
console.log("server çalıştı");
})