So I'm trying to do a bit of text mining from this website "https://www.bmkg.go.id/gempabumi/gempabumi-terkini.bmkg" - particularly from lines 452 until 1050 through the Developer's Sources. I haven't been able to do that successfully; and my goal is, after I succeed in doing so, I'll have to convert it into a dataframe with custom labels, then save it as a CSV file into my local drive.
Is my logic on achieving this goal correct, or am I getting it wrong to even begin with?
Here's what I have so far:
library(httr)
library(dplyr)
bmkg_current <- GET("https://www.bmkg.go.id/gempabumi/gempabumi-terkini.bmkg")
stringi::stri_enc_detect(content(bmkg_current, "raw")) //just to check encoding type
bmkg_text <- content(bmkg_current, type ="text", encoding = "ISO-8859-1")
bmkg_df <- tibble(line = 452:1050, text = bmkg_text)
bmkg_df //tried to output, but not want I wanted
Output:
# A tibble: 599 x 2
line text
<int> <chr>
1 452 "<!DOCTYPE html>\r\n<!--[if IE 8]> <html lang=\"en\" clas~
2 453 "<!DOCTYPE html>\r\n<!--[if IE 8]> <html lang=\"en\" clas~
3 454 "<!DOCTYPE html>\r\n<!--[if IE 8]> <html lang=\"en\" clas~
4 455 "<!DOCTYPE html>\r\n<!--[if IE 8]> <html lang=\"en\" clas~
5 456 "<!DOCTYPE html>\r\n<!--[if IE 8]> <html lang=\"en\" clas~
These are what lines 452 - 1050 look like in the HTML, from Developer Source:
<tr>
<td>2</td>
<td>29-Mar-20 <br>06:10:35 WIB</td>
<td>-7.39</td>
<td>124.19</td>
<td>5.2</td>
<td>631 Km</td>
<td>108 km BaratLaut ALOR-NTT</td>
</tr>
Any help on this would be much appreciated! Thank you :)