Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Changchengxinshengxt = &Spider{ Name: "长城新盛信托", Description: "长城新盛信托净值数据 [Auto Page] [http://www.gwxstrust.com/cn/page.jsp?id=24&pageIndex=1]", NotDefaultField: true, Namespace: func(*Spider) string { return "xintuo" }, SubNamespace: func(self *Spider, dataCell map[string]interface{}) string { return "fund_src_nav" }, EnableCookie: false, RuleTree: &RuleTree{ Root: func(ctx *Context) { Keys := ctx.GetKeyin() fmt.Println(Keys) webpage := 5 var configs []string configs = strings.Split(Keys, ",") for a := 0; a < len(configs); a++ { if strings.Contains(configs[a], "page=") { webpage, _ = strconv.Atoi(strings.TrimLeft(Keys, "page=")) fmt.Println(webpage) } } ctx.Aid(map[string]interface{}{"loop": [2]int{1, webpage}, "Rule": "生成请求"}, "生成请求") }, Trunk: map[string]*Rule{ "生成请求": { ItemFields: []string{ "基金ID", "名称", "净值", "累计净值", "估值日期", }, AidFunc: func(ctx *Context, aid map[string]interface{}) interface{} { page := 0 for loop := aid["loop"].([2]int); loop[0] < loop[1]; loop[0]++ { page++ ctx.AddQueue(&request.Request{ Url: "http://www.gwxstrust.com/cn/page.jsp?id=24&pageIndex=" + strconv.Itoa(loop[0]), Rule: aid["Rule"].(string), Temp: map[string]interface{}{ "level1pages": page, }, }) } return nil }, ParseFunc: func(ctx *Context) { query := ctx.GetDom() ss := query.Find(".m-t-10.tableProc tbody").Find("tr") var page1 int ctx.GetTemp("level1pages", &page1) count := 0 ss.Each(func(i int, goq *goquery.Selection) { titleLine := strings.TrimSpace(goq.Children().Eq(0).Text()) if titleLine != "产品名称" && titleLine != "" && titleLine != "12345" { mingchen := goq.Children().Eq(0).Text() jingzhi := goq.Children().Eq(1).Text() leijijingzhi := goq.Children().Eq(1).Text() guzhiriqi := goq.Children().Eq(2).Text() count++ fundID := "XTCHANGCHENXINSHENG" + "P1" + strconv.Itoa(page1) + "L" + strconv.Itoa(count) ctx.Output(map[int]interface{}{ 0: fundID, 1: mingchen, 2: jingzhi, 3: leijijingzhi, 4: guzhiriqi, }) } }) }, }, }, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.