igslim

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 8 Imported by: 0

README

igslim

Get Instagram user profile.

Docs: https://pkg.go.dev/github.com/caiguanhao/igslim

client := igslim.NewClient(os.Getenv("IGSESSIONID"))
user, err := client.GetUser("TaylorSwift")
if err != nil {
	panic(err)
}
enc := json.NewEncoder(os.Stdout)
enc.SetEscapeHTML(false)
enc.SetIndent("", "  ")
enc.Encode(user)
=== RUN   TestGetUser
{
  "Id": 11830955,
  "FbId": 17841401648650184,
  "UserName": "taylorswift",
  "FullName": "Taylor Swift",
  "Verified": true,
  "Picture": "https://scontent-hkt1-2.cdninstagram.com/v/t51.2885-19/s320x320/203390676_6325176860841825_830428569594643688_n.jpg?_nc_ht=scontent-hkt1-2.cdninstagram.com&_nc_ohc=il4wZ60N2tQAX9QjskR&tn=vkikvA8yTJv52AHZ&edm=ABfd0MgBAAAA&ccb=7-4&oh=14e473e45306615c7cf55ebb4afd27f5&oe=6150BAD1&_nc_sid=7bff83",
  "Biography": "Happy, free, confused and lonely at the same time. \nNov. 19th, 2021",
  "CategoryName": "Musician",
  "FollowingsCount": 0,
  "FollowersCount": 179511327,
  "PostsCount": 512
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchUser = errors.New("no such user")
	ErrFailed     = errors.New("failed to get user")
)

Functions

func GetUserNameFromText added in v1.1.0

func GetUserNameFromText(text, username string) string

GetUserNameFromText extracts Instagram user name from "text" (usually the biography of a social media account) using regular expressions. Because of too many edge cases, this function does not guarantee the accuracy of the extracted user names. The "username" argument is returned if Instagram is mentioned but no user name is found. Empty string is returned if no user name is found.

Types

type Client

type Client struct {
	SessionId string
}

func NewClient

func NewClient(sessionId string) *Client

Create new client with session id.

func (Client) GetUser

func (client Client) GetUser(username string) (*User, error)

GetUser wraps GetUserWithContext using context.Background.

func (Client) GetUserWithContext

func (client Client) GetUserWithContext(ctx context.Context, username string) (*User, error)

GetUserWithContext returns user info or error.

type User

type User struct {
	Id              int
	FbId            int64
	UserName        string
	FullName        string
	Verified        bool
	Picture         string
	Biography       string
	CategoryName    string
	FollowingsCount int
	FollowersCount  int
	PostsCount      int
}

Jump to

Keyboard shortcuts

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