Created
January 19, 2017 23:08
-
-
Save wmcraver/6ef9ce3a76aaefe2c507e92deab82a47 to your computer and use it in GitHub Desktop.
A quick script I use to extract key items from URLs. This makes quick work for double checking the structure of SEO/SEM URLs.
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(urltools) | |
# Read in the URLs | |
dat = read.csv("LandingPageURLs.csv", stringsAsFactors = F) | |
# Extract the scheme, domain, and path from the urls | |
dat$scheme = scheme(dat$LandingPage) | |
dat$domain = domain(dat$LandingPage) | |
dat$path = path(dat$LandingPage) | |
# Extract particular parameters from the URLs | |
x = param_get(dat$LandingPage, c("parameter1", "parameter2", "parameter3", "etc")) | |
#combine the original data set and the extracted parameters data set together into a new data frame | |
datNew = cbind(dat, x) | |
# Write the data frame to CSV | |
write.csv(datNew, "URL-Split.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment