Skip to content

Instantly share code, notes, and snippets.

@voltek62
Last active June 30, 2018 14:27
Show Gist options
  • Save voltek62/6570d299662185878493d7079f179ff1 to your computer and use it in GitHub Desktop.
Save voltek62/6570d299662185878493d7079f179ff1 to your computer and use it in GitHub Desktop.
get SEO metrics from SEMrush API with R
library(dplyr)
# https://dataseolabs.com
# Doc : https://fr.semrush.com/api-documentation/
# Get your key here : https://fr.semrush.com/billing-admin/profile/subscription/api-units
# conf
keyAPI <- "YOURKEY"
domain <- "cnn.com"
country <- "fr"
limit <- "1000"
url <- paste("http://api.semrush.com/?type=domain_organic&key=",keyAPI,"&display_limit=",limit,
"&export_columns=Ph,Po,Pp,Pd,Nq,Cp,Ur,Tr,Tc,Co,Nr,Td&domain=",domain,
"&display_sort=tr_desc&database=",country,sep="")
print(url)
# query API SEMrush
result <- read.csv( url, header = TRUE, sep=";", encoding = "UTF-8", stringsAsFactors=FALSE) %>%
arrange(Position)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment