parser

package
v0.0.0-...-3cf4c9a Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RE_HOST = regexp.MustCompile(`http(s)?://([\w-]+\.)+[\w-]+/?`)
	RE_HTML = regexp.MustCompile("(?is)<.*?>")
	RE_A    = regexp.MustCompile(`<a(.*?)href="http(.*?)"(.*?)>(.*?)</a>`)
	RE_HREF = regexp.MustCompile(`href=\"?(.*?)(\"|>|\\s+)`)
	RE_IMG  = regexp.MustCompile("(?is)<img .*?>")
	RE_SRC  = regexp.MustCompile(`src=\"?(.*?)(\"|>|\\s+)`)
)

Functions

func Register

func Register(name string, parser Parser)

Types

type CyParser

type CyParser struct {
	RegParser
	NormalParser
}

func (*CyParser) ParseHtml

func (this *CyParser) ParseHtml(post *models.Post) ([]string, error)

type NormalParser

type NormalParser struct {
}

func (*NormalParser) GetUrl

func (this *NormalParser) GetUrl(src string) string

type Parser

type Parser interface {
	ParseHtml(post *models.Post) ([]string, error)
}

func NewParser

func NewParser(parser_name string) (Parser, error)

type RegParser

type RegParser struct {
}

func (*RegParser) GetAs

func (this *RegParser) GetAs(body string) []string

func (*RegParser) GetImgs

func (this *RegParser) GetImgs(body string) []string

func (*RegParser) RemoveHtml

func (this *RegParser) RemoveHtml(src string) string

type RssParser

type RssParser struct {
	RegParser
}

func (*RssParser) ParseHtml

func (this *RssParser) ParseHtml(post *models.Post) ([]string, error)

Jump to

Keyboard shortcuts

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