Skip to content

Instantly share code, notes, and snippets.

@sergiospagnuolo

sergiospagnuolo/get_users.R. Secret

Last active May 21, 2021
Embed
What would you like to do?
get_users.R
library(rtweet)
library(tidyverse)
library(RPostgreSQL)
library(googlesheets4)
############################################################
# API CREDENTIALS
api_key <- ""
api_secret_key <- ""
access_token <- ""
access_token_secret <- ""
## authenticate via web browser
token <- create_token(
app = "nuclear_monitor",
consumer_key = api_key,
consumer_secret = api_secret_key,
access_token = access_token,
access_secret = access_token_secret)
############################################################
lista_users <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vR9zWCTNZBFGdnaGlPfweRmGOZ0d0F7hVTM-SQoMXjjOHpH8IIUGm5dOYd0G1P9cN39FL5HQ7cM_3Va/pub?gid=1069017284&single=true&output=csv", header = T)
users <- lookup_users(lista_users$screen_name)
experts <- users_data(users) %>% mutate(sqn_n = 1:n())
#write.csv(experts, "www/cientistas3.csv")
#CONNECT TO DATABASE
db <- dbConnect("PostgreSQL",
dbname = "",
host = "",
port = ,
user = "",
password = "")
#DROP OLD EXPERT DATABASE TABLE
dbExecute(db, "DROP TABLE experts")
dbWriteTable(db, "experts", experts, row.names=F)
dbListTables(db)
dbDisconnect(db)
# envia dados para Google Sheets
# sheet_write(experts, ss = "https://docs.google.com/spreadsheets/d/11W4Sw3M4pJ12yolY03UsU_lUDjnuaOYLYcldy4xZPfg/edit#gid=113454232", sheet = "experts")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment