Created
December 21, 2015 21:41
-
-
Save theseanco/abda7b1a5c4605c04087 to your computer and use it in GitHub Desktop.
Random Whois - Part 1 of HSS project to grab data from random
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
# a sample program to use ipwhois to dump info about a random IP address | |
# in order to use this you will need to install ipwhois using pip | |
import random | |
from ipwhois import IPWhois | |
from pprint import pprint | |
# getting four random numbers for the ipv4 address. Casting them as strings | |
r1 = str(random.randrange(255)) | |
r2 = str(random.randrange(255)) | |
r3 = str(random.randrange(255)) | |
r4 = str(random.randrange(255)) | |
# a way to join the four numbers as an ipv4 string | |
objseq = (r1, r2, r3, r4) | |
sep = "." | |
#joining the string and analysing it with ipwhois | |
obj = IPWhois(sep.join(objseq)) | |
results = obj.lookup() | |
print results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment