gopengraph

package module
v0.0.0-...-8ae8951 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MIT Imports: 2 Imported by: 1

README

Gopengraph CI Status

GopenGraph is a very simple Go library for parsing Open Graph protocol and Metadata information from web sites.

Installation

$ go get github.com/roperzh/gopengraph

Usage


import (
  "fmt"

  "github.com/PuerkitoBio/goquery"
  "github.com/roperzh/gopengraph"
)

// Directly from an URL
pageFromUrl := gopengraph.NewFromUrl("https://github.com/")

fmt.Printf("Title: %s, Description: %s", pageFromUrl.Title, pageFromUrl.Description)
// => Title: Build software better, together, Description: GitHub is ..

// From a *goquery.Document
doc, err := goquery.NewDocument(url)
pageFromDocument := gopengraph.New(doc)

fmt.Printf("og:site_name: %s, og:url: %s", pageFromDocument.OgAttrs["og:site_name"], pageFromDocument.OgAttrs["og:url"])
// => og:site_name: GitHub, og:url: https://github.com

Contributing

1- Fork it

2- Create your feature branch (git checkout -b my-new-feature)

3- Commit your changes (git commit -am 'Add some feature')

4- Push to the branch (git push origin my-new-feature)

5- Create new Pull Request

License

MIT License

Documentation

Overview

Package gopengraph

For a full guide visit https://github.com/roperzh/gopengraph

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GopenGraph

type GopenGraph struct {
	OgAttrs        map[string]string
	Title          string
	Description    string
	Url            string
	MandatoryAttrs []string
}

func New

func New(doc *goquery.Document) *GopenGraph

Build a new instance of the GopenGraph struct based on an already scrapped site

func NewFromUrl

func NewFromUrl(url string) (*GopenGraph, error)

Build a new instance of the GopenGraph Struct with an url string

func (*GopenGraph) IsValid

func (m *GopenGraph) IsValid() bool

Check if all MandatoryAttrs are present

func (*GopenGraph) PopulateAttrs

func (m *GopenGraph) PopulateAttrs(doc *goquery.Document)

Store the page Title and Description

func (*GopenGraph) PopulateOgTags

func (m *GopenGraph) PopulateOgTags(doc *goquery.Document)

Store all Open Graph tags (http://ogp.me/)

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/cascadia
The cascadia package is an implementation of CSS selectors.
The cascadia package is an implementation of CSS selectors.
_workspace/src/github.com/PuerkitoBio/goquery
Package goquery implements features similar to jQuery, including the chainable syntax, to manipulate and query an HTML document.
Package goquery implements features similar to jQuery, including the chainable syntax, to manipulate and query an HTML document.
_workspace/src/golang.org/x/net/html
Package html implements an HTML5-compliant tokenizer and parser.
Package html implements an HTML5-compliant tokenizer and parser.
_workspace/src/golang.org/x/net/html/atom
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
Package atom provides integer codes (also known as atoms) for a fixed set of frequently occurring HTML strings: tag names and attribute keys such as "p" and "id".
_workspace/src/golang.org/x/net/html/charset
Package charset provides common text encodings for HTML documents.
Package charset provides common text encodings for HTML documents.

Jump to

Keyboard shortcuts

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