-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get supported languages google
- Loading branch information
1 parent
57a4b5c
commit 3f20a38
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ Imports: | |
httr, | ||
magrittr, | ||
purrr, | ||
RCurl, | ||
rlang, | ||
rvest, | ||
stringr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' Get Supported Languages | ||
#' | ||
#' This function fetches the supported languages from the Google Cloud Translate documentation page. | ||
#' | ||
#' @return A data frame containing the supported languages and their corresponding ISO 639-1 codes. | ||
#' @export | ||
google_get_supported_languages <- function() { | ||
# Define the URL of the webpage | ||
url <- "https://cloud.google.com/translate/docs/languages" | ||
|
||
# Check if the URL is available | ||
if (!RCurl::url.exists(url)) { | ||
stop("The URL is not available.") | ||
} | ||
|
||
# Read the HTML of the webpage | ||
webpage <- rvest::read_html(url) | ||
|
||
# Select the table from the webpage | ||
table <- webpage %>% rvest::html_nodes('table') | ||
|
||
# Convert the HTML table into a data frame | ||
df <- table %>% rvest::html_table() | ||
|
||
# Convert the first table in the list into a data frame | ||
df_lang <- df[[1]] %>% tibble::as_tibble() | ||
|
||
return(df_lang) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.