instagram

package
v0.5.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

This code is borrowed from this repository with small changes https://github.com/omegaatt36/instagramrobot

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractShortcodeFromLink(link string) (string, error)

ExtractShortcodeFromLink will extract the media shortcode from a URL link or path

func GetPostWithCode

func GetPostWithCode(ctx context.Context, code string) (*models.Media, error)

GetPostWithCode lets you to get information about specific Instagram post by providing its unique shortcode

Types

type APIFetcher added in v0.5.0

type APIFetcher struct{}

APIFetcher is the legacy implementation that talks to Instagram's GraphQL / embed endpoints over plain HTTP. It is kept behind the Fetcher interface as a fallback; note that Instagram increasingly serves anti-bot challenges (error 1357054) to these anonymous requests, especially from datacenter IPs.

func NewAPIFetcher added in v0.5.0

func NewAPIFetcher() *APIFetcher

NewAPIFetcher creates the legacy HTTP-based fetcher.

func (*APIFetcher) GetPost added in v0.5.0

func (f *APIFetcher) GetPost(ctx context.Context, code string) (*models.Media, error)

GetPost implements Fetcher using the GraphQL/embed HTTP path.

type BrowserFetcher added in v0.5.0

type BrowserFetcher struct {
	// contains filtered or unexported fields
}

BrowserFetcher retrieves posts by loading the post page in a real (headless) browser via the shared browser.Manager. Because the requests originate from a genuine browser, Instagram's anti-bot layer serves the actual post instead of a challenge page — which is why this works where APIFetcher gets error 1357054. The media URLs are read from the page's embedded JSON; no cookies/tokens are needed.

func NewBrowserFetcher added in v0.5.0

func NewBrowserFetcher() *BrowserFetcher

NewBrowserFetcher creates a browser-based fetcher using the shared browser.

func (*BrowserFetcher) GetPost added in v0.5.0

func (f *BrowserFetcher) GetPost(ctx context.Context, code string) (*models.Media, error)

GetPost implements Fetcher by loading the post page in a real browser and parsing the embedded media JSON. The "/p/" path serves both single posts and reels (Instagram resolves the media by shortcode regardless of the path segment), and also carousels and photos.

type Fetcher added in v0.5.0

type Fetcher interface {
	GetPost(ctx context.Context, code string) (*models.Media, error)
}

Fetcher retrieves an Instagram post by its shortcode. Different implementations use different transports (anonymous HTTP API, headless browser, ...).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL