-
Notifications
You must be signed in to change notification settings - Fork 0
/
webscrapper.R
54 lines (35 loc) · 1.95 KB
/
webscrapper.R
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
#Synopsis Scraper (To scrape the opinion)
library(rvest)
library(dplyr)
movies = data.frame()
for (page_result in seq(from = 1, to = 48, by = 1)) {
link = paste0("https://infrastructure.planninginspectorate.gov.uk/projects/south-west/a303-stonehenge/?ipcsection=relreps&ipcpagesizesubmit=Apply&ipcsearch=&ipcpagesize=50&ipcpage=",
page_result, "#ipcprevnext")
page = read_html(link)
# name = page %>% html_nodes("#repstable strong") %>% html_text()
# movie_links = page %>% html_nodes("td") %>%
# html_attr("href") %>% paste("https://infrastructure.planninginspectorate.gov.uk/projects/south-west/a303-stonehenge/", ., sep="")
synopsis = page %>% html_nodes(".ipcrelrep") %>% html_text()
# date = sapply(movie_links, FUN = get_date, USE.NAMES = FALSE)
movies = rbind(movies, data.frame(synopsis, stringsAsFactors = FALSE))
print(paste("Page:", page_result))
}
write.csv(movies,"movies.csv")
# =IF(ISERROR(SEARCH(A2,B2,1)),B2,RIGHT(B2,LEN(B2)-LEN(A2)))
#Names Scraper (To scrape the names)
#library(rvest)
#library(dplyr)
names = data.frame()
for (page_result in seq(from = 1, to = 48, by = 1)) {
link = paste0("https://infrastructure.planninginspectorate.gov.uk/projects/south-west/a303-stonehenge/?ipcsection=relreps&ipcpagesizesubmit=Apply&ipcsearch=&ipcpagesize=50&ipcpage=",
page_result, "#ipcprevnext")
page = read_html(link)
name = page %>% html_nodes("#repstable strong") %>% html_text()
# movie_links = page %>% html_nodes("td") %>%
# html_attr("href") %>% paste("https://infrastructure.planninginspectorate.gov.uk/projects/south-west/a303-stonehenge/", ., sep="")
# synopsis = page %>% html_nodes(".ipcrelrep") %>% html_text()
names = rbind(names, data.frame(name, stringsAsFactors = FALSE))
print(paste("Page:", page_result))
}
write.csv(names,"names.csv")
# =IF(ISERROR(SEARCH(A2,B2,1)),B2,RIGHT(B2,LEN(B2)-LEN(A2)))