Last active
October 13, 2015 15:37
-
-
Save hky/4217235 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Date : 2014-12-16 21:37:26 | |
# @Author : Hengky Anwar (hky@lostfocus.org) | |
# @Link : http://lostfocus.org | |
# @Version : $Id$ | |
# alternate from whois -h whois.pandi.or.id domain.xx.id | |
# requirements | |
# pip install requests beautifulsoup4 | |
import sys | |
import requests | |
from bs4 import BeautifulSoup | |
# using cache | |
# pip install requests-cache | |
import requests_cache | |
requests_cache.install_cache('/tmp/requests_cache', backend='sqlite') | |
if len(sys.argv) <= 1: | |
print "usage: %s domain" % sys.argv[0] | |
sys.exit(1) | |
DOMAIN = sys.argv[1].replace(".id", "") | |
URL = "http://iddomain.dnet.net.id/pendaftaran-domain-baru/?url=%s&domain=id" % DOMAIN | |
HEADERS = { | |
'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' | |
} | |
s = requests.session() | |
r = s.get(URL, headers=HEADERS) | |
# print r.content # Debug | |
html = r.content | |
soup = BeautifulSoup(html) | |
# Retrieve all of the pre tags | |
if soup.pre is not None: | |
# tags = soup('pre') | |
tags = soup.find("pre").get_text().split('\n') | |
for tag in tags: | |
print tag.replace("<br>", "") | |
else: | |
print "not found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment