Last active
June 29, 2018 23:29
-
-
Save voltek62/32f5be4eb7ce8a379fe9854c09cce9fe to your computer and use it in GitHub Desktop.
get TF and CF from Majestic API with R
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
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