Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions R/getFilingsHTML.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ getFilingsHTML <- function(cik.no = "ALL", form.type = "ALL", filing.year,
filing.text <- filing.text ## In case opening and closing TEXT TAG not found, cosnider full web page
})


if(!grepl(pattern ='<xml>|<type>xml|<html>', filing.text, ignore.case=T)){

filing.text <- gsub("\t"," ", filing.text)
filing.text <- gsub("<CAPTION>|<S>|<C>", "", filing.text, ignore.case = T)
## Append with PRE to keep the text format as it is
filing.text <- c("<PRE style='font-size: 15px'>", filing.text, "</PRE>")
#Define problematic text function
remove_problematic_text <- function(t) {
t <- gsub("\t"," ", t)
t <- gsub("<CAPTION>|<S>|<C>", "", t, ignore.case = T)
## Append with PRE to keep the text format as it is
t <- c("<PRE style='font-size: 15px'>", t, "</PRE>")
}

ifelse(!grepl(pattern ='<xml>|<type>xml|<html>', filing.text, ignore.case=T),
remove_problematic_text(filing.text), filing.text)

## Form new dir and filename
new.dir <- paste0("Edgar filings_HTML view/Form ", f.type)
Expand Down