全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
11805 7
2015-01-18
悬赏 1500 个论坛币 已解决
1、主网址:http://cp.win007.com/buy/toto14.aspx?issueNum=20150042、凯利指数网址:http://cp.win007.com/1x2/1016700.html(对应威廉欧赔0.97 0.90 0.97)
3、必发交易数据网址:http://cp.win007.com/analysis/1016700.htm(需要价位、成交量、成交比,占9列)4、基础信息:只要( 场次 赛事   开赛时间    主队    客队  半场  全场  彩果)
5、数据框格式(赛事   开赛时间 场次  主队   客队  威廉   立博   澳彩亚赔  凯利指数  必发数据)
6、具备一定的通用性(修改期号就可抓其他的足彩数据比如:2015009)
希望R的达人,特别是戴申老师多使一层功力,菜虫跟着长长见识,嘿嘿。源码也可发到我的QQ:1034765971



最佳答案

daishen 查看完整内容

library(rvest) library(stringr) gamble = function(x){ url = str_c('http://cp.win007.com/buy/toto14.aspx?issueNum=',x) session = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>% html_nodes("td:nth-child(1)") %>% html_text() %>% .[-1] 场次 = session[seq(1,length(session),5)] event = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>% ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-1-18 14:52:52
library(rvest)
library(stringr)

gamble = function(x){

  url = str_c('http://cp.win007.com/buy/toto14.aspx?issueNum=',x)
  session = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
              html_nodes("td:nth-child(1)") %>% html_text() %>% .[-1]
  场次 = session[seq(1,length(session),5)]
  event = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
            html_nodes("td:nth-child(2)") %>% html_text() %>% .[-1]
  赛事 = event[seq(1,length(event),4)]
  开赛时间 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(3)") %>% html_text() %>% .[-1]
  主队 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(4)") %>% html_text() %>% .[-1] %>%
               str_replace('\r\n\t\t\t','')
  客队 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(5)") %>% html_text() %>% .[-1] %>%
               str_replace('\r\n\t\t\t','')
  分析 =  url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(12)") %>% html_text() %>% .[-1] %>%
               str_replace('\r\n\t\t\t\t','') %>% str_extract("亚 欧 析 统")

  状态 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(13)") %>% html_text()
  比分 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(14)") %>% html_text()
  半场 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(15)") %>% html_text()
  彩果 = url %>% html_session() %>% html_nodes("table") %>% .[[2]] %>%
               html_nodes("td:nth-child(16)") %>% html_text()
  基础信息 = data.frame(场次=场次,赛事=赛事,开赛时间=开赛时间,主队=主队,客队=客队,分析=分析,
                        状态=状态,比分=比分,半场=半场,彩果=彩果)

  u = str_c('http://cp.win007.com/handle/handicap.aspx?issuenum=',x,'&typeid=1&companyid=3&1420858993000')
  asia = u %>% html() %>% html_nodes("i") %>% html_text() %>% str_split(",") %>%
         do.call(rbind,.) %>% .[,c(2,4,5,6)] %>% as.data.frame
  asia = sapply(asia, function(x) as.numeric(as.character(x))) %>% as.data.frame
  皇冠亚赔 = asia[order(asia[,1]),][-1]

  v = str_c('http://cp.win007.com/handle/1x2.aspx?issuenum=',x,'&typeid=1&companyid=9&1420894723000')
  uro = v %>% html() %>% html_nodes("i") %>% html_text() %>% str_split(",") %>%
        do.call(rbind,.) %>% .[,c(2,7,8,9)] %>% as.data.frame
  uro = sapply(uro, function(x) as.numeric(as.character(x))) %>% as.data.frame
  威廉欧赔 = uro[order(uro[,1]),][-1]

  l = str_c('http://cp.win007.com/handle/1x2.aspx?issuenum=',x,'&typeid=1&companyid=-3&t=1421656460000')
  kaili = l %>% html() %>% html_nodes("i") %>% html_text() %>% str_split(",") %>%
          do.call(rbind,.) %>% as.data.frame
  kaili = sapply(kaili, function(x) as.numeric(as.character(x))) %>% as.data.frame
  凯丽指数 = kaili[order(kaili[,1]),][-1]

  b = str_c('http://cp.win007.com/handle/betfair.aspx?issuenum=',x,'&typeid=1&1421657087000')
  bifa = b %>% html() %>% html_nodes("i") %>% html_text() %>% str_split(",") %>%
         do.call(rbind,.) %>% as.data.frame
  bifa = sapply(bifa, function(x) as.numeric(as.character(x))) %>% as.data.frame %>% .[c(-1,-5)]
  必发指数 = bifa

  total = cbind(基础信息,威廉欧赔,皇冠亚赔,凯丽指数,必发指数)
  names(total) = c('场次','赛事','开赛时间','主队','客队','分析','状态','比分','半场','彩果','威廉1',
                   '威廉2','威廉3','皇冠1','皇冠2','皇冠3','凯丽1','凯丽2','凯丽3','必发1','必发2','必发3')   
  return(total)

  }

gamble(2015003)
   场次   赛事    开赛时间    主队    客队        分析 状态 比分 半场 彩果
13    1 英足总 01-06 03:45 伯恩利   热 刺  亚 欧 析 统 完场  1-1  0-0   平
12    2 英足总 01-06 03:55 温布尔  利物浦  亚 欧 析 统 完场  1-2  1-1   负
14    3 英足总 01-07 03:45 埃弗顿  西汉姆  亚 欧 析 统 完场  1-1  0-0   平
7     4   意甲 01-06 03:45 拉齐奥  桑普多  亚 欧 析 统 完场  3-0  2-0   胜
11    5   意甲 01-06 19:30 乌迪内   罗 马  亚 欧 析 统 完场  0-1  0-1   负
3     6   意甲 01-06 22:00  切 沃   都 灵  亚 欧 析 统 完场  0-0  0-0   平
8     7   意甲 01-06 22:00 AC米兰  萨索洛  亚 欧 析 统 完场  1-2  1-1   负
4     8   意甲 01-06 22:00 恩波利  维罗纳  亚 欧 析 统 完场  0-0  0-0   平
10    9   意甲 01-06 22:00 帕尔马  佛罗伦  亚 欧 析 统 完场  1-0  1-0   胜
5    10   意甲 01-06 22:00 热那亚  亚特兰  亚 欧 析 统 完场  2-2  0-1   平
9    11   意甲 01-06 22:00 巴勒莫  卡利亚  亚 欧 析 统 完场  5-0  3-0   胜
2    12   意甲 01-07 01:00 切塞纳  那不勒  亚 欧 析 统 完场  1-4  0-2   负
6    13   意甲 01-07 04:00  尤 文   国 米  亚 欧 析 统 完场  1-1  1-0   平
1    14   西甲 01-06 03:45 科尔多  格拉纳  亚 欧 析 统 完场  2-0  2-0   胜
   威廉1 威廉2 威廉3 皇冠1 皇冠2 皇冠3 凯丽1 凯丽2 凯丽3 必发1 必发2 必发3
13  3.50  3.50  2.05  0.98 -0.25  0.92  93.5  93.4  93.4  3.40  3.70  2.32
12 12.00  5.50  1.25  0.99 -1.75  0.90  93.1  93.0  93.0 14.50  7.20  1.26
14  1.95  3.50  3.80  0.86  0.50  1.04  93.1  93.1  93.2  1.97  3.90  4.20
7   1.75  3.60  4.80  0.95  0.75  0.96  94.5  94.5  94.5  1.79  3.75  5.80
11  4.33  3.40  1.83  1.01 -0.50  0.91  94.6  94.6  94.6  4.90  3.60  1.94
3   3.00  2.90  2.60  1.02  0.00  0.90  94.7  94.6  94.6  3.05  3.15  2.84
8   1.60  4.00  5.50  1.08  1.00  0.84  94.6  94.6  94.6  1.65  4.20  6.60
4   1.91  3.50  4.00  0.87  0.50  1.05  94.5  94.5  94.5  1.93  3.75  4.60
10  3.80  3.40  2.00  0.96 -0.50  0.95  94.5  94.5  94.5  4.50  3.60  2.00
5   2.10  3.20  3.60  0.90  0.25  1.01  94.7  94.7  94.7  2.26  3.30  3.95
9   2.05  3.25  3.80  0.89  0.25  1.03  94.7  94.7  94.7  2.22  3.40  3.95
2   9.00  4.60  1.36  1.06 -1.25  0.86  94.6  94.6  94.6 11.50  5.30  1.37
6   1.44  4.33  7.50  1.06  1.25  0.86  94.7  94.7  94.7  1.47  4.80  9.40
1   2.50  2.87  3.20  1.20  0.25  0.75  94.5  94.5  94.5  2.62  3.15  3.30
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-18 16:06:28
提示: 作者被禁止或删除 内容自动屏蔽
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-18 16:58:10
不是大神老师吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-18 20:49:41
谢谢楼上提供的网址,停电刚上来.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-18 21:29:09
方便起见在上次的基础上新增凯利指数和必发指数组成数据框即可,另外需考虑通用性,谢谢!
凯利指数存在http://1x2.nowscore.com/1016700.js上,估计得先从主页上找到每场比赛的ScheduleID
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群