http://www.tiyuxiu.com
这种列表是api渲染,详情是链接的情况,需要这样设置
~~~
package main
import (
"encoding/json"
articleSpider "github.com/PeterYangs/article-spider/v3"
)
func main() {
f := articleSpider.Form{
Host: "http://www.tiyuxiu.com",
Channel: "/data/list_0_[PAGE].json?__t=16339338",
PageStart: 1,
Length: 10,
DetailFields: map[string]articleSpider.Field{
"title": {Types: articleSpider.Text, Selector: "h1"},
"content": {Types: articleSpider.HtmlWithImage, Selector: "#main-content"},
},
ApiConversion: func(html string, form *articleSpider.Form) []string {
type list struct {
Url string
}
var l []list
json.Unmarshal([]byte(html), &l)
var temp []string
for _, l2 := range l {
temp = append(temp, l2.Url)
}
return temp
},
}
s := articleSpider.NewSpider(f, articleSpider.Api)
s.Start()
}
~~~
**ApiConversion**需要自行处理出详情链接的切片
如这个api
![](https://img.kancloud.cn/ae/9f/ae9fd6909b3e945b1dc8fa8c503a2b87_1082x369.png)
**ApiConversion**需要返回 **[]string{"/article/559643.html","/article/559644.html"}**