-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 946 Bytes
/
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
const axios = require('axios')
const qs = require('qs')
exports.jump = async(req, res) => {
if(req.query.keyword){
return gettag(req, res)
}
}
const getUrl = async(url, data='', headers='', method='GET') => {
headers = headers ? headers : {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'}
const options = {
method: method,
headers: headers,
data: data,
url
}
return await axios(options)
.then(async (res) => {
return res.data
})
.catch(async (err) => {
await setTimeout(() => console.log(' To Reconnect !'), 6000);
throw new Error(err)
})
}
const gettag = async(req, res) => {
let url = 'https://www.instagram.com/explore/tags/'+req.query.keyword+'/?__a=1'
let json = await getUrl(url, '', headers)
res.status(200).send(json.json)
}