src/api/instagram.js
/**
     * Read the posts that are pre-loaded on the page
     */
Read the posts that are pre-loaded on the page
Read the posts that are pre - loaded on the page
async scrapeDefaultPosts() {
        const shortCodes = await this.page.evaluate((url) => {
            return Array.from(document.links)
                .filter((link) => {
                return (link.href.startsWith(url) &&
                    link.href.split("/").length >= 2);
            })
                .map((link) => {
                const linkSplit = link.href.split("/");
                return linkSplit[linkSplit.length - 2];
            });
        }, this.defaultPostURL);
        for (const shortCode of shortCodes) {
            if (this.index < this.total || this.total === 0) {
                this.index++;
                this.pagePromises.push(this.postPage(shortCode, this.postPageRetries));
            }
            else {
                this.finished = true;
                break;
            }
        }
    }
async scrapeDefaultPosts ( ) { const shortCodes = await this . page . evaluate ( ( url ) => { return Array . from ( document . links ) . filter ( ( link ) => { return ( link . href . startsWith ( url ) && link . href . split ( "/" ) . length >= 2 ) ; } ) . map ( ( link ) => { const linkSplit = link . href . split ( "/" ) ; return linkSplit [ linkSplit . length - 2 ] ; } ) ; } , this . defaultPostURL ) ; for ( const shortCode of shortCodes ) { if ( this . index < this . total || this . total === 0 ) { this . index ++ ; this . pagePromises . push ( this . postPage ( shortCode , this . postPageRetries ) ) ; } else { this . finished = true ; break ; } } }
Read the posts that are pre-loaded on the page
Read the posts that are pre - loaded on the page
// Get shortcodes from page /* istanbul ignore next */ // Add postPage promises