M1n007 / node-insta-web-api

Simple, easy implementation of the Instagram private web API.
42 stars 17 forks source link

bypass instagram challenge #11

Open ozkcs opened 3 years ago

ozkcs commented 3 years ago

make a feature to bypass instagram challenge login attempt

M1n007 commented 3 years ago

otw

xiguayizu commented 2 years ago

can i fix it?

xiguayizu commented 2 years ago

\node-insta-web-api\lib\index.js change code:

    async _getSharedData(url = this.baseUrl) {
        try{
            var getText = await this.requestNodeFetch.getText(url, this.headers);
            if( getText.res != undefined ){
                // 如果被风控
                var res_text = JSON.parse(getText.res.text)
                var challenge = await this.requestNodeFetch.post("https://www.instagram.com/challenge/", "choice=0&next=%2Faccounts%2Fedit%2F", this.headers)
                console.log( challenge )
                console.log("challenge is coming... and pass")
                // 重新获取
                getText = await this.requestNodeFetch.getText(url, this.headers);
            }
            const _sharedData = helpers.getString('<script type="text/javascript">window._sharedData =', '};</script>', getText);
            const resultJsonStringData = `${_sharedData[1]}}`;
            const resultJson = JSON.parse(resultJsonStringData);
            return resultJson;
        }catch(e){
            throw new Error(e)
        }
    }