Created
February 14, 2016 01:41
-
-
Save QuanSai/a051251204f1ed2ddcf9 to your computer and use it in GitHub Desktop.
Extract domain expiration data from domain.com
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
import sys | |
import urllib2 | |
from bs4 import BeautifulSoup | |
if __name__=="__main__": | |
REGISTRAR = "http://whois.com/whois/" | |
# ask the user for the domain name if a domain was not passed in | |
try: | |
domain = sys.argv[1] | |
except IndexError: | |
domain = raw_input("Domain?: ") | |
domain_to_check = REGISTRAR + domain | |
# requests to the registrar | |
registrar_response = urllib2.Request(domain_to_check) | |
status_page_text = urllib2.urlopen(registrar_response) # raw html text | |
# store the page as a BeautifulSoup object | |
parsed_status_page = BeautifulSoup(status_page_text, "html.parser") | |
expiration_date = parsed_status_page.find('div', | |
class_='whois_result', | |
id='registryData') | |
# filter the <br>'s found in the status section of the page | |
expiration = filter(lambda x: x.text.startswith('Expiration Date'), expiration_date.findAll('br')) | |
# clean the expiration status (remove extra whitespace) and the prefix "Expiration Date" | |
expiration_date = expiration[0].text.split(':')[1].strip() | |
# tell that bitch wtf it is... ya heard meh? | |
print "The expiration date for '{}' is {}".format(domain, expiration_date) |
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
beautifulsoup4==4.4.1 | |
urllib3==1.14 | |
wsgiref==0.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get this to work, download both files and inside of the directory (unzip them or whatever):
pip install -r requirements.txt
Then, type
python domainexp.py cool.com
If you don't specify a domain name, you'll be prompted to specify one.