-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiteration.R
More file actions
73 lines (43 loc) · 1.64 KB
/
iteration.R
File metadata and controls
73 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
nombres <- c("jorge","jacky","elias","daniel","nikol","oscar")
for(i in nombres){
saludo <- paste0("Hola ", i, "!")
print(saludo)
}
#-----------------------------------------------
df <- data.frame()
for(i in nombres){
saludo <- paste0("Hola ", i, "!")
df <- rbind(df, saludo)
}
#----------------------------------------------
for(año in seq(from = 2016, to = 2022, by = 2)){
mensaje <- paste("El", año, "fue el mejor año")
print(mensaje)
}
#----------------------------------------------
library(rvest) # HTML Hacking & Web Scraping
library(tidyverse) # Data Manipulation
# Guardar URL -------------------------------------------------------------
url <- "https://repositorioacademico.upc.edu.pe/handle/10757/621444/recent-submissions"
# Leer HTML ---------------------------------------------------------------
page <- read_html(url)
page
titulo <- page %>% html_nodes(".list-title-clamper") %>% html_text()
titulo
#Loop para 3 páginas
for (page_result in seq(from = 0, to = 40, by = 20)) {
link <- paste0("https://repositorioacademico.upc.edu.pe/handle/10757/621444/recent-submissions?offset=",
page_result)
print(link)
}
#-------------------------------------------------------
df <- data.frame()
#Loop para 3 páginas
for (page_result in seq(from = 0, to = 40, by = 20)) {
link <- paste0("https://repositorioacademico.upc.edu.pe/handle/10757/621444/recent-submissions?offset=",
page_result)
page <- read_html(link)
titulo <- page %>% html_nodes(".list-title-clamper") %>% html_text()
df <- rbind(df, data.frame(titulo))
print(paste("Página:",(page_result/20)+1))
}