Skip to content

Instantly share code, notes, and snippets.

@jgamblin
Created May 4, 2017 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgamblin/eaab0066e7942dcb8f822f5cb7fdc72e to your computer and use it in GitHub Desktop.
Save jgamblin/eaab0066e7942dcb8f822f5cb7fdc72e to your computer and use it in GitHub Desktop.
library(leaflet)
library(tidyverse)
library(httr)
library(rvest)
library(jsonlite)
library(ipapi)
#devtools::install_github("hrbrmstr/ipapi")
#Find geo Containing Key Word
punch_it <- function(dom) {
POST(url = "https://domainpunch.com/tlds/search.php",
query = list(w=dom),
add_headers(
Origin = "https://domainpunch.com",
`User-Agent` = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.29 Safari/537.36",
Referer = "https://domainpunch.com/tlds/search.php",
`X-Requested-With` = "XMLHttpRequest")) -> res
stop_for_status(res)
res <- content(res, as="text", encoding="UTF-8")
res <- jsonlite::fromJSON(res, flatten=FALSE)
if (length(res$table)>0) {
ret <- read_html(res$table) %>% html_table() %>% .[[1]]
as_tibble(ret[-1,-1])
} else {
NULL
}
}
sites <- punch_it("defcon")
sites$Zone <- NULL
sites$Info <- NULL
sites$Length <- NULL
#Do GeoLookup
locations <- mutate(geolocate(sites$Domain))
geo <- cbind(sites, locations)
geo <- subset(geo, status!="fail")
#Build Map:
m <- leaflet(geo) %>% addTiles('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png')
m %>% addMarkers(clusterOptions = markerClusterOptions(), ~lon, ~lat, popup = paste("DNS:", geo$Domain, "<br>",
"IP:", geo$query, "<br>",
"ISP", geo$isp, "<br>",
"ASN:", geo$as ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment