Skip to content

Commit

Permalink
Try Fix axios in render#10
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Aug 12, 2023
1 parent 1f53a38 commit 1cb62b1
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions lib/api/apidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,42 +679,45 @@ function pinterest(querry){

function igstory (username) {
return new Promise(async(resolve, reject) => {
const res = await axios.get('https://storydownloader.app/en',{
axios.get('https://storydownloader.app/en',{
headers: {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
}
}).catch(error => resolve())
const $ = cheerio.load(res.data)
var token = $('body > main > div.hero.pt-5.pb-5 > div.container.w > div > form > div.input-group.mb-2 > input[type=hidden]:nth-child(2)').attr('value')
axios.request({
url: 'https://storydownloader.app/request',
method: 'post',
data: new URLSearchParams(Object.entries({ 'username': username, '_token': token })),
headers: {
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'cookie': res.headers["set-cookie"]
})
.then(res => {
const $ = cheerio.load(res.data)
var token = $('body > main > div.hero.pt-5.pb-5 > div.container.w > div > form > div.input-group.mb-2 > input[type=hidden]:nth-child(2)').attr('value')
axios.request({
url: 'https://storydownloader.app/request',
method: 'post',
data: new URLSearchParams(Object.entries({ 'username': username, '_token': token })),
headers: {
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'cookie': res.headers["set-cookie"]
}
}).then(respon => {
if(!respon.data.html) {
return resolve()
}else{
const $ = cheerio.load(respon.data.html)
let hasil = []
$('div.row > div').each(function (a, b) {
hasil.push({
image: $(b).find('img').attr('src'),
url_download: $(b).find('a').attr('href')
})
})
const result = {
username: $('h3.card-title').text(),
profile_picture: $('img.card-avatar').attr('src'),
url: hasil
}
return resolve(result)
}
}).then(respon => {

if(!respon.data.html) {
}).catch(reject => {
return resolve()
}else{
const $ = cheerio.load(respon.data.html)
let hasil = []
$('div.row > div').each(function (a, b) {
hasil.push({
image: $(b).find('img').attr('src'),
url_download: $(b).find('a').attr('href')
})
})
const result = {
username: $('h3.card-title').text(),
profile_picture: $('img.card-avatar').attr('src'),
url: hasil
}
return resolve(result)
}
}).catch(error => resolve())
})
})
}

Expand Down

0 comments on commit 1cb62b1

Please sign in to comment.