// 分析网页抓取开奖结果 func analyzeHtml(html string) ([]entity.SuperLotto, error) { // 使用正则分析网页 regex := regexp.MustCompile(`<td height="23" align="center" bgcolor="(#f9f9f9|E4E4E4)">(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>(\d+)</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>\S+</td>[^>]*?>.*?</td>[^>]*?>.*?</td>[^>]*?>.*?</td>[^>]*?>(\S+)</td>[^<]*?</tr>`) group := regex.FindAllStringSubmatch(html, -1) //log.Println(group) //log.Println("共计:", len(group)) results := make([]entity.SuperLotto, 0) for _, section := range group { item := entity.SuperLotto{} item.ID = crypto.GetUniqueInt64() item.No = section[2] item.Date = section[10] item.Red1, _ = strconv.Atoi(section[3]) item.Red2, _ = strconv.Atoi(section[4]) item.Red3, _ = strconv.Atoi(section[5]) item.Red4, _ = strconv.Atoi(section[6]) item.Red5, _ = strconv.Atoi(section[7]) item.Blue1, _ = strconv.Atoi(section[8]) item.Blue2, _ = strconv.Atoi(section[9]) results = append(results, item) } return results, nil }