-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (46 loc) · 1.71 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
import express from "express";
import request from "request";
import Cheerio from "cheerio";
import router from "./router/index.js";
const app =express();
app.use(express.urlencoded({ extended: true }));
// var ref,price,dispo,paiment;
// var json={ref:"",price:"",dispo:"",paiment:""}
// app.get('/reference',(req,res)=>{
// // scarping code
// const url = "https://www.tunisianet.com.tn/pc-portable-tunisie/60036-copy-of-pc-portable-hp-victus-15-fb0022nk-i7-12700h-8-go-gtx-1650-4g.html";
// request(url,function (error,response,html){
// var $ = Cheerio.load(html)
// $(".product-reference").filter(function(){
// var data =$(this);
// var reference = data.children().eq(1).text();
// json.ref=reference;
// console.log( reference)
// })
// $(".current-price").filter(function(){
// var data =$(this);
// var price = data.children().eq(0).text();
// console.log(price)
// json.price=price;
// })
// $("#stock_availability").filter(function(){
// var data =$(this);
// var dispo = data.children().eq(0).text();
// console.log(dispo)
// json.dispo=dispo;
// })
// $(".product-prices-ntimes-mobile").filter(function(){
// var data =$(this);
// var faciliter = data.children().eq(0).text();
// console.log(faciliter)
// json.paiment=faciliter;
// })
// console.log(json)
// res.json(json)
// })
// })
app.use(express.json());
app.use(router);
app.listen(5000,()=>{
console.log("server is listen on port 5000 ");
})