更新Spiderfile模版

This commit is contained in:
marvzhang
2019-12-03 14:25:54 +08:00
parent 98cbccb81e
commit 40f6675ce8
2 changed files with 3 additions and 3 deletions

View File

@@ -225,7 +225,7 @@ func (g ScrapyGenerator) GetExtractStringFromField(f entity.Field) string {
// 如果为XPath
if f.Attr == "" {
// 文本
return fmt.Sprintf(`xpath('%s/text()')`, f.Xpath)
return fmt.Sprintf(`xpath('string(%s)')`, f.Xpath)
} else {
// 属性
return fmt.Sprintf(`xpath('%s/@%s')`, f.Xpath, f.Attr)

View File

@@ -11,9 +11,9 @@ stages:
page_attr: "href"
fields:
- name: "title"
css: "h3 > a"
xpath: ".//h3/a"
- name: "url"
css: "h3 > a"
xpath: ".//h3/a"
attr: "href"
- name: "abstract"
css: ".c-abstract"