-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
164 lines (152 loc) · 5.75 KB
/
server.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// const request = require('request');
// request.get('/',function(req,res,next){
// console.log(req,'====')
// console.log(res,'====')
// request('https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1',(err,response,body)=>{
// if(!err&&response.statusCode == 200){
// var data=JSON.parse(body);
// console.log('101',data)
// response.render('index', data);
// }
// })
// })
// fetch("https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1",
// {
// "credentials":"include",
// "headers":{
// "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
// "accept-language":"zh-CN,zh;q=0.9,en;q=0.8",
// "cache-control":"no-cache",
// "pragma":"no-cache",
// "upgrade-insecure-requests":"1"
// },
// "referrerPolicy":"no-referrer-when-downgrade",
// "body":null,
// "method":"GET",
// "mode":"cors"
// }
// );
// const fetch = require("node-fetch");
// const HttpsProxyAgent = require('https-proxy-agent');
// // let url="https://ip.nf/me.json";
// let url="https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1";
// let ip='代理服务的IP';
// let port='代理服务的端口';
// fetch(url, {
// method: 'GET',
// // body: null,
// redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect
// timeout: 10000, //ms
// agent: new HttpsProxyAgent("http://" + ip + ":" + port) //<==注意是 `http://`
// }).then(function (res) {
// console.log("Response Headers ============ ");
// res.headers.forEach(function(v,i,a) {
// console.log(i+" : "+v);
// });
// return res.text();
// }).then(function (res) {
// console.log("Response Body ============ ");
// console.log(res);
// });
// const express = require("express");
// const fetch = require("node-fetch");
// const request = require('request');
// const app = express()
// const host = process.env.HOST || '0.0.0.0'
// const port = process.env.PORT || 3000
// app.set('port', port)
// app.all('*', function (req, res, next) {
// if (!req.get('Origin')) return next();
// // use "*" here to accept any origin
// res.set('Access-Control-Allow-Origin', '*');
// res.set('Access-Control-Allow-Methods', 'GET');
// res.set('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type');
// // res.set('Access-Control-Allow-Max-Age', 3600);
// if ('OPTIONS' == req.method) return res.send(200);
// next();
// });
// app.get('/ShopEvaluate/:type', function (req, res) {
// // var sreq = request.get(host + req.originalUrl)
// res.status(200),
// // res.json({a:123})
// fetch('https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1', {
// method: 'GET',
// // body: null,
// redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect
// timeout: 10000, //ms
// "credentials":"include",
// "headers":{
// "accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
// "accept-language":"zh-CN,zh;q=0.9,en;q=0.8",
// "cache-control":"no-cache",
// "pragma":"no-cache",
// "upgrade-insecure-requests":"1"
// },
// "referrerPolicy":"no-referrer-when-downgrade",
// "body":null,
// "method":"GET",
// "mode":"cors"
// }).then(function (res) {
// console.log("Response Headers ============ ",res);
// // res.headers.forEach(function(v,i,a) {
// // console.log(i+" : "+v);
// // });
// return res.text();
// }).then(function (res) {
// console.log("Response Body ============ ");
// console.log(res);
// });
// // request('https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1',(err,response,body)=>{
// // if(!err&&response.statusCode == 200){
// // var data=JSON.parse(body);
// // console.log('101',data)
// // res.json(data)
// // // response.render('index', data);?
// // // sreq.pipe(res);
// // // sreq.on('end', function (error, res) {
// // // console.log('end');
// // // });
// // }
// // })
// })
// async function start() {
// app.listen(port,host);
// console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
// }
// start()
// var request = require("request");
// var express = require("express");
// var app = express();
// app.get("/index", (req, res) => {
// request({
// url: "https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1",
// method: "GET",
// json: true,
// // headers: {
// // "content-type": "application/json",
// // },
// // body: JSON.stringify(req.body)
// }, function(error, response, body) {
// if (error) {
// console.log('-------------------1-----------------');
// console.log(error);
// res.send(error);
// res.end();
// console.log('------------------------------------');
// }else{
// console.log('-----------------2-------------------');
// console.log(res);
// console.log('------------------------------------');
// res.send(JSON.stringify(body));
// res.end();
// }
// });
// })
// app.listen(3000);
const request = require('request')
return request({
url: "https://rate.tmall.com/list_detail_rate.htm?itemId=547788307274&sellerId=1¤tPage=1",
method: "GET"
}, (err, res, body) => {
console.log(body)
})