link2json

package module
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

README

Simple wrapper using colly to extract webpage metadata and export it as JSON. Only parses items defined in the the opengraph spec.

Todo

  • Test cases ( May be :) )

Dependencies

Depends on

  • gocolly/colly
  • patrickmn/go-cache
  • sirupsen/logrus

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LINK2JSON_DEBUG bool
)

Functions

func IsUrl added in v1.0.12

func IsUrl(str string) bool

Types

type ImageField added in v1.0.9

type ImageField struct {
	URL string `json:"url"`
}

func (*ImageField) UnmarshalJSON added in v1.0.9

func (i *ImageField) UnmarshalJSON(data []byte) error

type MetaDataResponseItem

type MetaDataResponseItem struct {
	Title       string     `json:"title"`
	Description string     `json:"description"`
	Images      []WebImage `json:"images"`
	Sitename    string     `json:"sitename"`
	Favicon     string     `json:"favicon"`
	Duration    int        `json:"duration"`
	Domain      string     `json:"domain"`
	URL         string     `json:"url"`
}

func GetMetadata

func GetMetadata(targetURL string) (*MetaDataResponseItem, error)

type WebImage

type WebImage struct {
	URL    string `json:"url"`
	Alt    string `json:"alt,omitempty"`
	Type   string `json:"type,omitempty"`
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
}

Jump to

Keyboard shortcuts

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