HLN, Parool: fix relatief xpath
This commit is contained in:
@@ -179,7 +179,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
}
|
||||
article := articles[0]
|
||||
|
||||
live, err := article.Search(`//*[@data-test-id="live-blog-label"]`)
|
||||
live, err := article.Search(`.//*[@data-test-id="live-blog-label"]`)
|
||||
p(err)
|
||||
if len(live) > 0 {
|
||||
fp, err := os.Create(filename + ".skip")
|
||||
@@ -189,7 +189,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
return true
|
||||
}
|
||||
|
||||
headers, err := article.Search(`//header`)
|
||||
headers, err := article.Search(`.//header`)
|
||||
p(err)
|
||||
if len(headers) == 0 {
|
||||
_ = w(fmt.Errorf("no header: %s", url))
|
||||
@@ -212,7 +212,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
header := headers[0]
|
||||
|
||||
tags := make([]string, 0)
|
||||
ell, err := header.Search(`//*[@data-test-id="article-label"]`)
|
||||
ell, err := header.Search(`.//*[@data-test-id="article-label"]`)
|
||||
p(err)
|
||||
if len(ell) == 0 {
|
||||
_ = w(fmt.Errorf("no labels: %s", url))
|
||||
@@ -226,7 +226,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
|
||||
pars := make([]string, 0)
|
||||
|
||||
ell, err = header.Search(`//*[@data-test-id="article-title"]`)
|
||||
ell, err = header.Search(`.//*[@data-test-id="article-title"]`)
|
||||
p(err)
|
||||
if len(ell) != 1 {
|
||||
_ = w(fmt.Errorf("found %d titles: %s", len(ell), url))
|
||||
@@ -239,7 +239,7 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
}
|
||||
|
||||
found := false
|
||||
ell, err = header.Search(`//*[@data-test-id="header-intro"]`)
|
||||
ell, err = header.Search(`.//*[@data-test-id="header-intro"]`)
|
||||
p(err)
|
||||
for _, el := range ell {
|
||||
s := strings.TrimSpace(el.Content())
|
||||
@@ -252,13 +252,13 @@ func doArticle(filename string, url string, timestamp time.Time, needUpdate bool
|
||||
_ = w(fmt.Errorf("no intro: %s", url))
|
||||
}
|
||||
|
||||
specials, err := article.Search(`//section//aside | //section//figure | //section//b`)
|
||||
specials, err := article.Search(`.//section//aside | .//section//figure | .//section//b`)
|
||||
p(err)
|
||||
for _, special := range specials {
|
||||
special.Remove()
|
||||
}
|
||||
|
||||
ell, err = article.Search(`//section//*[@data-article-element-index]`)
|
||||
ell, err = article.Search(`.//section//*[@data-article-element-index]`)
|
||||
p(err)
|
||||
if len(ell) == 0 {
|
||||
_ = w(fmt.Errorf("no elements: %s", url))
|
||||
|
||||
Reference in New Issue
Block a user