你好嗎?我正在嘗試訪問特定的體育博彩網站,我想獲取正在播放的足球比賽的名稱,但是當我嘗試時,我只能訪問所有事件名稱,我不知道為什么。我正在使用這段代碼:
library(rvest)
library(tidyverse)
library(xml2)
html="https://www.supermatch.com.uy/live_recargar_menu/"
a=rvest::read_html(html)
b2= a %>% html_node("body") %>% html_node(xpath="//li[@class='sport code_sport-1']") %>%
html_nodes(xpath="//span[@class='titulo']") %>% html_text()
如您所見,此代碼獲取所有正在播放的事件的名稱。
uj5u.com熱心網友回復:
library(tidyverse)
library(rvest)
page <- "https://www.supermatch.com.uy/live_recargar_menu/" %>%
read_html()
tibble(
title = page %>%
html_elements(".titulo") %>%
html_text(),
score = page %>%
html_elements(".marcador") %>%
html_text(),
time = page %>%
html_elements(".marcador span") %>%
html_text() %>%
str_squish()
)
# A tibble: 15 × 3
title score time
<chr> <chr> <chr>
1 CS Emelec - Atletico Mineiro 0:1 1a parte 18'
2 Nacional de Montevideo - Union de Santa Fe 1:0 1a parte 18'
3 Brusque FC - Esporte Clube Bahia 0:1 PT 34'
4 Gremio FBPA - Londrina 1:0 PT 34'
5 Fulgencio Yegros - Deportivo Santani 2:0 2a parte 76'
6 Paraguay - Panama 2:0 2a parte 65'
7 Venezuela U20 - Bolivia U20 26:10 2do cuarto 6'
8 Liu, L - Parikh, H 1:1 3er set
9 Truwit, Teddy - Raab, J 0:0 1er Set
10 Ngounoue, M - Woog, M 1:0 2do set
11 Cheng, E - Lopez, Jackeline 1:0 2do set
12 Moore, M - Pratt, S 0:1 2do set
13 Zhu, Jiayun - Horwood, S 0:0 1er Set
14 Nguyen, M - White, M 0:0 1er Set
15 Martincova, T - Pliskova, Karolina 0:0 No iniciado
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/496991.html
上一篇:swift“maximumLengthOfBytes(using:)”和“lengthOfBytes(using:)”有什么區別
