Through Media.info I was able to retrieve very few handles. Thus I resorted to extracting twitter handles from the available websites in my directory. Not all urls were still active, but luckily some of them redirected to their new sites. One example is the Evening Express, which is now under the Press and Journal, in Aberdeen.
From 1059 web urls, I manage to extract 450 handles.
# twitter_profiles <-
# readRDS("directory_with_hyperlocals.RDS") %>% select(Publication,
# Twitter.x,
# Twitter.y,
# `Twitter url`,
# `Twitter handle`) %>% mutate(Twitter = coalesce(Twitter.x, Twitter.y, `Twitter handle`)) %>% select(-`Twitter handle`) %>% filter(!is.na(`Twitter url`)) %>% mutate(twitter_handle = str_remove(Twitter, "@")) %>% select(Publication, twitter_handle)
#
# # urls <-
# # directory_final %>% select(Publication, Website) %>% na.omit() %>%
# # mutate(Website = str_remove(Website, ".* "))
# #
# # # due to many webistes urls in my list having changed over time, here below, I rewrite my list to include redirected urls, then extract twitter handles from the redirection pages
# # urls$redirect_url <-
# # do.call(rbind, lapply(urls$Website, function(x) {
# # try(GET(x)$url)
# # }))
# # urls <-
# # urls %>% mutate(redirect_url = if_else(
# # str_detect(redirect_url, "Error"),
# # NA_character_,
# # redirect_url
# # ))
# # urls$twitter <- lapply(urls$redirect_url, function(url) {
# # try(read_html(url) %>% html_elements(xpath = "//a[contains(@href, 'twitter.com/')]/@href") %>% html_text())
# # })
# # urls <- urls %>% rowwise %>% mutate(types = length(unique(twitter)),
# # twitter = list(pluck(twitter, 1)))
# # saveRDS(urls, "urls.RDs")
#
# urls <- readRDS("urls.RDS")
#
# urls <- urls %>%
# filter(!is.null(twitter)) %>%
# mutate(
# twitter = unlist(twitter),
# twitter = if_else(str_detect(twitter, "Error"), NA_character_, twitter)
# ) %>%
# filter(!is.na(twitter)) %>%
# mutate(
# twitter_handle = str_remove(twitter, ".*twitter.com/"),
# twitter_handle = str_remove(twitter_handle, "\\?.*"),
# twitter_handle = str_remove(twitter_handle, "\\/.*"),
# twitter_handle = str_remove(twitter_handle, "@")
# ) %>%
# full_join(twitter_profiles, by = c("Publication", "twitter_handle")) %>%
# select(twitter_handle, Publication) %>%
# filter(twitter_handle != "459701824769900545") %>%
# mutate(twitter_handle = if_else(Publication == "North Edinburgh Community News", "NorthEdinbNews", twitter_handle)) %>%
# pivot_wider(names_from = twitter_handle, values_from = Publication) %>%
# pivot_longer(cols = everything()) %>%
# rowwise %>%
# mutate(titles_under_handle = length(unique(value)))
#
# urls$name[438] <- "myturriff"
#
# plot <- ggplot(urls, aes(x = titles_under_handle)) +
# geom_histogram(fill = "lightslateblue") +
# theme_minimal() +
# labs(x = "Number of titles per handle", y = "Number of titles")
#
# jpgfile <-
# fs::path(knitr::fig_path(), "titles_by_twitterhandle.jpeg")
# ggsave(
# jpgfile,
# plot,
# width = 40,
# height = 10,
# units = "cm",
# scaling = 2
# )
# knitr::include_graphics(jpgfile)
5 Analysing engagement with local news outlets on social media
In this Chapter, I use my AcademicTwitter API access to extract and analyse engagement on Twitter between local news outlets and their communities.
5.1 Data Collection
5.1.1 Twitter handles
Through Media.info I was able to retrieve very few handles. Thus I resorted to extracting twitter handles from the available websites in my directory. Not all urls were still active, but luckily some of them redirected to their new sites. One example is the Evening Express, which is now under the Press and Journal, in Aberdeen.
From 1059 web urls, I manage to extract 450 handles.
5.1.2 News outlets id and profile information
5.1.3 Tweets
Got all 2020, 2021, and 2022 tweets for 450 of my news outlets.
5.1.4 Twitter profile followers
This took forever but now it’s done.
5.1.5 Tweet retweeters
I have paused this.
5.1.6 Tweet likers
I have paused this.
5.2 Analysis
5.2.1 Outlet location vs followers location
5.2.2 Outlet location vs engagers location
5.2.3 Post location vs engagers location