/
upcoming_floats.R
53 lines (52 loc) · 2.4 KB
/
upcoming_floats.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
upcoming_floats <- function(){
##Gather company names, ticker, and market cap for a metal
library(rvest)
library(plyr)
library(XML)
url <- "http://www.asx.com.au/prices/upcoming.htm"
html <- rvest::html(url)
htmlnodes <- html_nodes(x = html, css = "td")
data <- html_text(htmlnodes, trim = TRUE)
data1 <- as.data.frame(matrix(data = data,ncol = 3,byrow = TRUE),stringsAsFactors = FALSE)
colnames(data1) <- c("Company","Proposed ASX Code","Proposed Listing Date/Time")
doc <- htmlParse(url)
links <- xpathSApply(doc, "//a/@href")
free(doc)
links <- as.data.frame(matrix(data = links,ncol = 1,byrow = TRUE),stringsAsFactors = FALSE)
links <- links[grepl(pattern = "upcomingFloat",x = links[,1],ignore.case = TRUE)==TRUE,]
links <- as.data.frame(matrix(data = links,ncol = 1,byrow = TRUE),stringsAsFactors = FALSE)
links$Link <- NA
i <- 1
while(i<=nrow(links)){
links$Link[i] <- paste("http://www.asx.com.au",links$V1[i],sep = "")
i <- i+1
}##End While
announcements <- cbind(data1,Links = links[,2])
announcements
}
recent_floats <- function(){
##Gather company names, ticker, and market cap for a metal
library(rvest)
library(plyr)
library(XML)
url <- "http://www.asx.com.au/asx/research/recentFloats.do"
html <- rvest::html(url)
htmlnodes <- html_nodes(x = html, css = "td")
data <- html_text(htmlnodes, trim = TRUE)
data1 <- as.data.frame(matrix(data = data,ncol = 6,byrow = TRUE),stringsAsFactors = FALSE)
colnames(data1) <- c("Company","ASX Code","Listing Date","Open","Close","")
doc <- htmlParse(url)
links <- xpathSApply(doc, "//a/@href")
free(doc)
links <- as.data.frame(matrix(data = links,ncol = 1,byrow = TRUE),stringsAsFactors = FALSE)
links <- links[grepl(pattern = "company.do",x = links[,1],ignore.case = TRUE)==TRUE,]
links <- as.data.frame(matrix(data = links,ncol = 1,byrow = TRUE),stringsAsFactors = FALSE)
links$Link <- NA
i <- 1
while(i<=nrow(links)){
links$Link[i] <- paste("http://www.asx.com.au",links$V1[i],sep = "")
i <- i+1
}##End While
announcements <- cbind(data1,Links = links[,2])
announcements
}