mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
更新Spiderfile模版
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user