allow empty description or content
This commit is contained in:
parent
c46706c32e
commit
f78345ab14
@ -50,10 +50,10 @@ type Specs struct {
|
|||||||
SelectorPost string `json:"selector_post" validate:"selector"`
|
SelectorPost string `json:"selector_post" validate:"selector"`
|
||||||
SelectorTitle string `json:"selector_title" validate:"selector"`
|
SelectorTitle string `json:"selector_title" validate:"selector"`
|
||||||
SelectorLink string `json:"selector_link" validate:"selector"`
|
SelectorLink string `json:"selector_link" validate:"selector"`
|
||||||
SelectorDescription string `json:"selector_description" validate:"selector"`
|
SelectorDescription string `json:"selector_description" validate:"omitempty,selector"`
|
||||||
SelectorAuthor string `json:"selector_author" validate:"selector"`
|
SelectorAuthor string `json:"selector_author" validate:"selector"`
|
||||||
SelectorCreated string `json:"selector_created" validate:"selector"`
|
SelectorCreated string `json:"selector_created" validate:"selector"`
|
||||||
SelectorContent string `json:"selector_content" validate:"selector"`
|
SelectorContent string `json:"selector_content" validate:"omitempty,selector"`
|
||||||
SelectorEnclosure string `json:"selector_enclosure" validate:"selector"`
|
SelectorEnclosure string `json:"selector_enclosure" validate:"selector"`
|
||||||
CacheLifetime string `json:"cache_lifetime"`
|
CacheLifetime string `json:"cache_lifetime"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -287,14 +287,18 @@ func (p *pageParser) extractPost(post playwright.Locator) (models.FeedItem, erro
|
|||||||
page, _ := post.Page()
|
page, _ := post.Page()
|
||||||
item.Link = absUrl(item.Link, page)
|
item.Link = absUrl(item.Link, page)
|
||||||
|
|
||||||
item.Description = p.must(post.Locator(p.task.SelectorDescription).First().InnerText(defOptInText))
|
if len(p.task.SelectorDescription) > 0 {
|
||||||
|
item.Description = p.must(post.Locator(p.task.SelectorDescription).First().InnerText(defOptInText))
|
||||||
|
}
|
||||||
|
|
||||||
item.AuthorName = p.must(post.Locator(p.task.SelectorAuthor).First().InnerText(defOptInText))
|
item.AuthorName = p.must(post.Locator(p.task.SelectorAuthor).First().InnerText(defOptInText))
|
||||||
|
|
||||||
item.AuthorLink = p.must(post.Locator(p.task.SelectorAuthor).First().GetAttribute("href", defOptAttr))
|
item.AuthorLink = p.must(post.Locator(p.task.SelectorAuthor).First().GetAttribute("href", defOptAttr))
|
||||||
item.AuthorLink = absUrl(item.AuthorLink, page)
|
item.AuthorLink = absUrl(item.AuthorLink, page)
|
||||||
|
|
||||||
item.Content = p.extractContent(post)
|
if len(p.task.SelectorContent) > 0 {
|
||||||
|
item.Content = p.extractContent(post)
|
||||||
|
}
|
||||||
|
|
||||||
item.Enclosure = p.must(post.Locator(p.task.SelectorEnclosure).First().GetAttribute("src", defOptAttr))
|
item.Enclosure = p.must(post.Locator(p.task.SelectorEnclosure).First().GetAttribute("src", defOptAttr))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user