pholcus_lib

package
v0.0.0-...-9397c3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Zhongshanzq = &Spider{
	Name:        "中山证券私募基金",
	Description: "中山证券私募基金数据 [Auto Page] [http://ov.zszq.com/product/jh1/jh1-1.asp]",

	NotDefaultField: true,

	Namespace: func(*Spider) string {
		return "zhengquan"
	},

	SubNamespace: func(self *Spider, dataCell map[string]interface{}) string {
		return "fund_src_nav"
	},

	EnableCookie: false,
	RuleTree: &RuleTree{

		Root: func(ctx *Context) {
			ctx.Aid(map[string]interface{}{"loop": [2]int{1, 2}, "Rule": "生成请求"}, "生成请求")
		},

		Trunk: map[string]*Rule{

			"生成请求": {

				AidFunc: func(ctx *Context, aid map[string]interface{}) interface{} {

					for loop := aid["loop"].([2]int); loop[0] < loop[1]; loop[0]++ {
						ctx.AddQueue(&request.Request{
							Url:  "http://ov.zszq.com/product/jh1/jh1-1.asp",
							Rule: aid["Rule"].(string),
						})
					}

					return nil
				},

				ParseFunc: func(ctx *Context) {

					query := ctx.GetDom()

					ss := query.Find(".bg tbody").Find("tr")

					ss.Each(func(i int, goq *goquery.Selection) {

						url, exist := goq.Children().Eq(0).Find("a").Attr("href")
						if exist == true {

							strings.Replace(url, "1.asp", "4.asp", -1)

							ctx.AddQueue(&request.Request{
								Url:  "http://ov.zszq.com" + url,
								Rule: "获取结果",
							})
						}
					})
				},
			},

			"获取结果": {
				ParseFunc: func(ctx *Context) {
					query := ctx.GetDom()
					ss := query.Find(".border tbody").Find("tr")
					fmt.Println(ss)
				},
			},
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL