BochilTeam / scraper

scraper module
GNU General Public License v3.0
99 stars 62 forks source link

Switch instagram parsing to other #90

Closed ghost closed 1 month ago

ghost commented 11 months ago

To download post, story, reel from Instagram, I recommend you to parse this site: https://storiesig.info/en/ Please!

BochilGaming commented 11 months ago

I've tried to scrape that website, but it returned negative -- Response code 401 (Unauthorized). Here is my code

import got from 'got'
import { InstagramdlArgsSchema } from '../types/index.js'
import { DEFAULT_HEADERS } from './constant.js'
import { generateHash, parseCookies, stringifyCookies } from './util.js'

export default async function instagramdlv2 (url: string) {
    InstagramdlArgsSchema.parse(arguments)

    const response = await got.get('https://storiesig.info/en/', {
        headers: {
            ...DEFAULT_HEADERS
        }
    })
    const stringify = stringifyCookies(response.headers['set-cookie']!)
    const parsed = parseCookies(stringify)
    console.log(parsed)
      const form = {
        ts: Date.now(),
        url,
        _s: generateHash(url),
        _ts: 1696501219803,
        _tsc: 0
    }
    const data = await got.post('https://storiesig.info/api/convert', {
        headers: {
            ...DEFAULT_HEADERS,
            cookie: stringify,
            origin: 'https://storiesig.info',
            'X-Xsrf-Token': parsed['XSRF-TOKEN']
        },
        json: form
    })
    throw data
}

Feel free to make a pull request in @bochilteam/scraper-instagram if you successfully scrape that website

BochilGaming commented 1 month ago

Try to use @bochilteam/scraper 5.0.1 version