全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
5030 15
2015-01-09
悬赏 500 个论坛币 已解决
求助:原来手工录入足彩数据,现在想着用R进行足彩网页数据采集,主页网址:http://cp.win007.com/buy/toto14.aspx?issueNum=2015004

将14场(行)足球比赛对阵名称(列),欧赔(列)、亚赔(列)比分(列)数据采集下来组成dataframe,
A:欧赔网址:http://cp.win007.com/1x2/1016700.html
欧赔只要抓威廉希尔的一组初盘数据2.25   3.1   3.4 即可
B:亚赔网址:http://cp.win007.com/handicap/1016700.html
亚赔只要抓澳彩的一组即时数据
0.90平手/半球0.96
即可.
期待达人指点

最佳答案

daishen 查看完整内容

library(rvest) library(stringr) url = 'http://cp.win007.com/buy/toto14.aspx?issueNum=2015004' 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)") ...
二维码

扫码加我 拉你入群

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

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

全部回复
2015-1-9 21:30:47
library(rvest)
library(stringr)

url = 'http://cp.win007.com/buy/toto14.aspx?issueNum=2015004'
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 = 'http://cp.win007.com/handle/handicap.aspx?issuenum=2015004&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[,1] = as.numeric(asia[,1])
皇冠亚赔 = asia[order(asia[,1]),][-1]

v = 'http://cp.win007.com/handle/1x2.aspx?issuenum=2015004&typeid=1&companyid=9&1420859179000'
uro = v %>% html() %>% html_nodes("i") %>% html_text() %>% str_split(",") %>% do.call(rbind,.) %>% .[,c(2,7,8,9)] %>% as.data.frame

uro[,1] = as.numeric(uro[,1])
威廉欧赔 = uro[order(uro[,1]),][-1]

total = cbind(基础信息,威廉欧赔,皇冠亚赔)

> total
   场次 赛事    开赛时间    主队    客队        分析 状态 比分 半场 彩果   V2    V3    V4   V2    V3   V4
8     1 西甲 01-10 03:45 莱万特  拉科鲁  亚 欧 析 统 完场  0-0  0-0   平 2.25  3.00  3.60 0.86  0.25 1.06
3     2 西杯 01-08 03:00 比利亚   社 会  亚 欧 析 统 完场  1-0  0-0   胜 1.73  3.40  4.50 0.91   0.5 0.99
6     3 西杯 01-08 04:00 马竞技   皇 马  亚 欧 析 统 完场  2-0  0-0   胜 1.57  3.50  6.00 0.85  0.75 1.05
7     4 西杯 01-08 05:00 巴伦西  西班人  亚 欧 析 统 完场  2-1  1-0   胜 2.05  3.10  3.60 0.89  0.25 1.01
4     5 西杯 01-08 05:00 阿尔梅  赫塔费  亚 欧 析 统 完场  1-1  0-1   平 2.15  2.90  3.50 0.78  0.25 1.13
5     6 西杯 01-09 03:00 格拉纳  塞维利  亚 欧 析 统 完场  1-2  0-1   负 1.50  3.75  6.50 0.90  0.75 1.00
13    7 西杯 01-09 05:00  巴 萨  埃尔切  亚 欧 析 统 完场  5-0  3-0   胜 1.55  4.00  6.00 0.85  0.75 1.05
14    8 法甲 01-08 03:30  里 尔  伊维恩  亚 欧 析 统 完场  1-0  0-0   胜 3.00  3.20  2.40 0.80 -0.25 1.11
11    9 法甲 01-10 03:30 蒙彼利   马 赛  亚 欧 析 统 完场  2-1  1-0   胜 1.67  3.80  5.00 1.09     1 0.81
9    10 法乙 01-10 03:00 阿雅克   尼 姆  亚 欧 析 统 完场  0-1  0-0   负 2.60  3.00  2.90 0.94     0 0.96
12   11 法乙 01-10 03:00 阿弗尔  沙托鲁  亚 欧 析 统 完场  1-1  0-0   平 4.60  3.30  1.83 1.13  -0.5 0.78
10   12 法乙 01-10 03:00 尼奥尔  阿雅GF  亚 欧 析 统 完场  1-1  0-1   平 1.06 11.00 34.00 1.01  3.25 0.89
1    13 法乙 01-10 03:00 克莱蒙  拉瓦勒  亚 欧 析 统 完场  0-0  0-0   平 1.70  3.40  5.50 0.97  0.75 0.93
2    14 法乙 01-10 03:00  第 戎   图 尔  亚 欧 析 统 完场  0-3  0-1   负 4.00  3.40  1.95 0.86  -0.5 1.04
二维码

扫码加我 拉你入群

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

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

2015-1-10 13:44:42
daishen 发表于 2015-1-10 12:38
library(rvest)
library(stringr)
u = 'http://cp.win007.com/handle/handicap.aspx?issuenum=2015004&typeid=1&companyid=3&1420858993000'

学习了,这个地址怎么找到的??
二维码

扫码加我 拉你入群

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

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

2015-1-10 14:20:55
dataorz 发表于 2015-1-10 13:44
u = 'http://cp.win007.com/handle/handicap.aspx?issuenum=2015004&typeid=1&companyid=3&1420858993000 ...
QQ截图20150110141752.png
二维码

扫码加我 拉你入群

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

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

2015-1-10 14:42:22
搞不明白这种赌球网站,按照楼主给的链接,亚赔澳彩的数据是这样:
q = 'http://cp.win007.com/handicap/1016700.html'
> q %>% html() %>% html_nodes("table") %>% .[[2]] %>% html_table(fill = T) %>% .[9,]
   X 1   NA        NA   NA   NA        NA NA NA         NA
9 澳彩 0.86 平手/半球 1.00 0.86 平手/半球  1    主 客 同

不是楼主给的数据。
二维码

扫码加我 拉你入群

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

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

2015-1-10 14:59:14
怎么不一样呢,找不到地址,求指导
怎么不一样.jpg
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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