microdata

Parser for HTML microdata, schema.org

  • 所有者: namsral/microdata
  • 平台:
  • 许可证: BSD 2-Clause "Simplified" License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Microdata

Microdata is a package for the Go programming language to extract HTML Microdata from HTML5 documents. It depends on the golang.org/x/net/html HTML5-compliant parser.

HTML Microdata is a markup specification often used in combination with the schema collection to make it easier for search engines to identify and understand content on web pages. One of the most common schema is the rating you see when you google for something. Other schemas are persons, places, events, products, etc.

Installation

Single binaries for Linux, macOS and Windows are available on the release page.

Or build from source:

$ go get -u github.com/namsral/microdata/cmd/microdata

Usage

Parse an URL:

$ microdata https://www.gog.com/game/...
{
  "items": [
    {
      "type": [
        "http://schema.org/Product"
      ],
      "properties": {
        "additionalProperty": [
          {
            "type": [
              "http://schema.org/PropertyValue"
            ],
{
...

Parse HTML from the stdin:

$ cat saved.html, microdata

Format the output with a Go template to return the "price" property:

$ microdata -format '{{with index .Items 0}}{{with index .Properties "offers" 0}}{{with index .Properties "price" 0 }}{{ . }}{{end}}{{end}}{{end}}' https://www.gog.com/game/...
8.99

Features

  • Windows/BSD/Linux supported
  • Format output with Go templates
  • Parse from Stdin

Contribution

Bug reports and feature requests are welcome. Follow GiHub's guide to using-pull-requests

Go Package

package main

import (
	"encoding/json"
	"os"

	"github.com/namsral/microdata"
)

func main() {
	var data microdata.Microdata
	data, _ = microdata.ParseURL("http://example.com/blogposting")
	b, _ := json.MarshalIndent(data, "", "  ")
	os.Stdout.Write(b)
}

For documentation see godoc.org/github.com/namsral/microdata.

主要指标

概览
名称与所有者namsral/microdata
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证BSD 2-Clause "Simplified" License
所有者活动
创建于2015-03-31 13:34:19
推送于2016-10-10 13:57:05
最后一次提交2016-10-10 15:57:00
发布数1
最新版本名称v0.1.0 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数34
关注者数4
派生数7
提交数27
已启用问题?
问题数2
打开的问题数2
拉请求数0
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?