parent
6775fe5100
commit
ec899f0ddf
|
@ -5,6 +5,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/net/html"
|
"golang.org/x/net/html"
|
||||||
|
@ -22,6 +23,8 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrCorruptedImage = errors.New("Corrupted image.")
|
ErrCorruptedImage = errors.New("Corrupted image.")
|
||||||
|
|
||||||
|
rxNewlines = regexp.MustCompile(`(?:\r?\n)*`)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -105,7 +108,7 @@ func (p *Parser) Parse(u *url.URL, referer *url.URL) (result parsers.ParseResult
|
||||||
title, ok := scrape.Find(root, scrape.ByTag(atom.Title))
|
title, ok := scrape.Find(root, scrape.ByTag(atom.Title))
|
||||||
if ok {
|
if ok {
|
||||||
// Got it!
|
// Got it!
|
||||||
result.Information[0]["Title"] = scrape.Text(title)
|
result.Information[0]["Title"] = rxNewlines.ReplaceAllString(scrape.Text(title), " ")
|
||||||
} else {
|
} else {
|
||||||
// No title found
|
// No title found
|
||||||
result.Information[0]["Title"] = "(no title)"
|
result.Information[0]["Title"] = "(no title)"
|
||||||
|
|
Loading…
Reference in New Issue