Skip to content

Instantly share code, notes, and snippets.

@voltek62
Last active June 29, 2018 23:29
Show Gist options
  • Save voltek62/32f5be4eb7ce8a379fe9854c09cce9fe to your computer and use it in GitHub Desktop.
Save voltek62/32f5be4eb7ce8a379fe9854c09cce9fe to your computer and use it in GitHub Desktop.
get TF and CF from Majestic API with R
library(httr)
library(urltools)
library(dplyr)
# https://dataseolabs.com
# Doc : https://developer-support.majestic.com/api/
# Create your key here : https://developer-support.majestic.com/security/
apiUrl <- "https://api.majestic.com/api/json?app_api_key="
apiKey <- "YOURKEY"
myList <- c("https://www.cuisineaz.com","http://www.marmiton.org")
#historic : all period
#refresh : 90 last days
modeUrl <- "historic"
# create empty dataframe
results <- data.frame()
for (site in myList) {
u <- url_encode(site)
url <- paste(apiUrl,apiKey,"&cmd=GetIndexItemInfo&items=1&item0=",u,"&datasource=",modeUrl,sep="")
req <- GET(url)
# you can add your own columns, check content(req)$DataTables$Results$Data
tmp <- as.data.frame(content(req)$DataTables$Results$Data) %>%
select(Item,ExtBackLinks,RefDomains,CitationFlow,TrustFlow)
results <- rbind(results,tmp)
}
print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment