sitemap

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 6 Imported by: 0

README

sitemap-parser

Golang sitemap parser for .xml and .gz

Build Statuscodecov

Install

go get github.com/Z-M-Huang/sitemap-parser

Example

Get Index
	index, err := sitemap.GetIndex("https://raw.githubusercontent.com/Z-M-Huang/sitemap-parser/master/test/sample_index.xml")
Get Sitemap
	index, err := sitemap.GetSitemap("https://raw.githubusercontent.com/Z-M-Huang/sitemap-parser/master/test/sample_index.xml")
Get Sitemap in GZ
	index, err := sitemap.GetSitemapGZ("https://github.com/Z-M-Huang/sitemap-parser/raw/master/test/sample_sitemap.xml.gz"")
Get All Sitemaps in Index
	index, _ := sitemap.GetIndex("https://raw.githubusercontent.com/Z-M-Huang/sitemap-parser/master/test/sample_index.xml")
	sitemaps, err := index.GetSitemaps()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Loc        string  `xml:"loc"`
	LastMod    string  `xml:"lastmod"`
	ChangeFreq string  `xml:"changefreq"`
	Priority   float32 `xml:"priority"`
}

Element single sitemap element

type Index

type Index struct {
	XMLName  xml.Name  `xml:"sitemapindex"`
	Elements []Element `xml:"sitemap"`
}

Index sitemap index

func GetIndex

func GetIndex(url string) (*Index, error)

GetIndex get sitemap index from URL

func (*Index) GetSitemaps

func (i *Index) GetSitemaps() ([]*Sitemap, error)

GetSitemaps loads all sitemaps from index

type Sitemap

type Sitemap struct {
	XMLName  xml.Name  `xml:"urlset"`
	Elements []Element `xml:"url"`
}

Sitemap sitemap data

func GetSitemap

func GetSitemap(url string) (*Sitemap, error)

GetSitemap get sitemap from URL

func GetSitemapGZ

func GetSitemapGZ(url string) (*Sitemap, error)

GetSitemapGZ get sitemaps from .gz URL

Jump to

Keyboard shortcuts

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