Skip to content

Commit 91b16dc

Browse files
committed
Also scrape LinkedIn
1 parent 405d78d commit 91b16dc

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

R/buildtools.R

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ get_maintainer_info <- function(path = '.'){
465465
login <- Sys.getenv('MAINTAINERLOGIN', "")
466466
if(nchar(login)){
467467
info$login <- tolower(login)
468-
info$mastodon <- scrape_github_mastodon(login)
469-
info$bluesky <- scrape_github_bluesky(login)
468+
info$mastodon <- scrape_github_social(login, "Mastodon")
469+
info$bluesky <- scrape_github_social(login, "Bluesky")
470+
info$linkedin <- scrape_github_social(login, "LinkedIn")
470471
}
471472
uuid <- Sys.getenv('MAINTAINERUUID', "")
472473
if(nchar(uuid)){
@@ -487,20 +488,10 @@ get_maintainer_info <- function(path = '.'){
487488
return(info)
488489
}
489490

490-
scrape_github_mastodon <- function(login){
491+
scrape_github_social <- function(login, network = c('Bluesky', 'Mastodon', 'LinkedIn')){
491492
tryCatch({
492493
doc <- xml2::read_html(paste0("http://github.com/", login))
493-
link <- xml2::xml_find_all(doc, '//li[svg/title = "Mastodon"]/a')
494-
if(length(link)){
495-
xml2::xml_attr(link, 'href')
496-
}
497-
}, error = message)
498-
}
499-
500-
scrape_github_bluesky <- function(login){
501-
tryCatch({
502-
doc <- xml2::read_html(paste0("http://github.com/", login))
503-
link <- xml2::xml_find_all(doc, '//li[svg/title = "Bluesky"]/a')
494+
link <- xml2::xml_find_all(doc, sprintf('//li[svg/title = "%s"]/a', network))
504495
if(length(link)){
505496
xml2::xml_attr(link, 'href')
506497
}

0 commit comments

Comments
 (0)