forked from ukamnya/microdata_mirror
Format examples and lint markdown
parent
ccf4160317
commit
7b1ac7f510
29
README.md
29
README.md
|
@ -1,4 +1,5 @@
|
||||||
# microdata
|
# microdata
|
||||||
|
|
||||||
A microdata parser in Go
|
A microdata parser in Go
|
||||||
|
|
||||||
See [http://www.w3.org/TR/microdata/](http://www.w3.org/TR/microdata/) for more information about Microdata
|
See [http://www.w3.org/TR/microdata/](http://www.w3.org/TR/microdata/) for more information about Microdata
|
||||||
|
@ -13,20 +14,20 @@ Simply run
|
||||||
|
|
||||||
Documentation is at [http://godoc.org/github.com/iand/microdata](http://godoc.org/github.com/iand/microdata)
|
Documentation is at [http://godoc.org/github.com/iand/microdata](http://godoc.org/github.com/iand/microdata)
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Example of parsing a string containing HTML:
|
Example of parsing a string containing HTML:
|
||||||
|
|
||||||
package main
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/iand/microdata"
|
"github.com/iand/microdata"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
html := `<div itemscope>
|
html := `<div itemscope>
|
||||||
<p>My name is <span itemprop="name">Elizabeth</span>.</p>
|
<p>My name is <span itemprop="name">Elizabeth</span>.</p>
|
||||||
</div>`
|
</div>`
|
||||||
|
@ -40,13 +41,15 @@ Example of parsing a string containing HTML:
|
||||||
}
|
}
|
||||||
|
|
||||||
println("Name: ", data.Items[0].Properties["name"][0].(string))
|
println("Name: ", data.Items[0].Properties["name"][0].(string))
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Extract microdata from a webpage and print the result as JSON
|
Extract microdata from a webpage and print the result as JSON
|
||||||
|
|
||||||
package main
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -54,9 +57,9 @@ Extract microdata from a webpage and print the result as JSON
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/iand/microdata"
|
"github.com/iand/microdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
baseUrl, _ := url.Parse("http://www.designhive.com/blog/using-schemaorg-microdata")
|
baseUrl, _ := url.Parse("http://www.designhive.com/blog/using-schemaorg-microdata")
|
||||||
|
|
||||||
|
@ -71,17 +74,15 @@ Extract microdata from a webpage and print the result as JSON
|
||||||
|
|
||||||
json, _ := data.JSON()
|
json, _ := data.JSON()
|
||||||
os.Stdout.Write(json)
|
os.Stdout.Write(json)
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
|
|
||||||
* [Ian Davis](http://github.com/iand) - <http://iandavis.com/>
|
* [Ian Davis](http://github.com/iand) - <http://iandavis.com/>
|
||||||
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
* Do submit your changes as a pull request
|
* Do submit your changes as a pull request
|
||||||
|
|
Loading…
Reference in New Issue