Esempio n. 1
0
def get_domain_info(domain):
    if is_domain(domain):
        url = 'http://searchdns.netcraft.com/?restriction=site+contains&host={0}&lookup=wait..&position=limited'\
            .format(domain)
        try:
            headers = {
                'User-Agent':
                "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"
            }
            result = requests.get(url, headers=headers).text
            bs = BeautifulSoup(result, 'html.parser')
            content = bs.find('div', id="content")
            if content is not None:
                rule = re.compile('(\/\?host=)')
                finally_result = rule.sub(
                    'http://searchdns.netcraft.com/?host=', content.prettify())
                script_path = os.path.abspath(
                    os.path.dirname(os.path.dirname(__file__)))
                finally_path = os.path.join(
                    script_path, 'output/{0}'.format("subdoamin.html"))
                sty = '<head><meta charset="UTF-8"><link href="../static/subdomain.css" rel="stylesheet" ' \
                    'type="text/css" /></head>'
                out_page(finally_path, sty, finally_result)

        except Exception as e:
            print(e)
Esempio n. 2
0
def get_sub_info(domain):
    session = requests.session()
    if is_domain(domain):
        url = 'http://i.links.cn/subdomain/'
        new_value = []
        try:
            payload = {'b2': 1, 'b3': 1, 'b4': 1, 'domain': domain}
            result = session.post(url, data=payload,
                                  headers=config.headers).text
            bs = BeautifulSoup(result, 'html.parser')
            content = bs.find_all('a', attrs={'rel': "nofollow"})
            if content is not None:
                for i in content:
                    if i.text:
                        new_value.append(i.text)
            f = xlwt.Workbook(encoding='utf-8', style_compression=0)
            sheet = f.add_sheet('sub', cell_overwrite_ok=True)
            script_path = os.path.abspath(
                os.path.dirname(os.path.dirname(__file__)))
            finally_path = os.path.join(script_path,
                                        'output/{0}'.format("subdomain.xls"))
            if len(new_value) != 0:
                for index, item in enumerate(new_value):
                    sheet.write(index, 0, item)
                f.save(finally_path)

        except Exception as e:
            print(e)
Esempio n. 3
0
def get_rebots_info(domain):
    if is_domain(domain):
        try:
            finally_url = "http://" + domain + '/robots.txt'
            result = http_get(finally_url)
            return result
            # script_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
            # finally_path = os.path.join(script_path, 'output/{0}'.format("robots.txt"))
            # if result:
            #     with open(finally_path, 'wb') as f:
            #         f.write(result.encode('utf-8'))
        except Exception as e:
            # print(e)
            return "robots not find"
Esempio n. 4
0
def dns(domain):
    if is_domain(domain):
        url = 'https://who.is/dns/{0}'.format(domain)
        try:
            result = http_get(url)
            bs = BeautifulSoup(result, 'html.parser')
            content = bs.find('table')
            script_path = os.path.abspath(
                os.path.dirname(os.path.dirname(__file__)))
            finally_path = os.path.join(script_path,
                                        'output/{0}'.format("dns.html"))
            sty = '<head><meta charset="UTF-8"><link href="../static/Bootstrap.css" rel="stylesheet" ' \
                  'type="text/css" /><link href="../static/main.css" rel="stylesheet" type="text/css" /></head>'
            out_page(finally_path, sty, content)

        except Exception as e:
            print(e)
Esempio n. 5
0
def get_who_is_page(domain):
    if is_domain(domain):
        url = "http://whois.chinaz.com/{0}".format(domain)
        payload = {'DomainName': domain}
        try:
            content = http_post(url, payload)
            bs = BeautifulSoup(content, 'html.parser')
            ul = bs.find('ul', class_="WhoisLeft")
            if ul is not None:
                script_path = os.path.abspath(
                    os.path.dirname(os.path.dirname(__file__)))
                finally_path = os.path.join(
                    script_path,
                    '..\\templates\\output\\{0}'.format("whois2.html"))
                sty = '<head><meta charset="UTF-8"> <link rel="stylesheet" href="../../static/css/whois.css"> ' \
                    '<link rel="stylesheet" href="../../static/css/whois_base.css"></head>'
                out_page(finally_path, sty, ul.prettify())
        except Exception as e:
            print(e)
Esempio n. 6
0
def get_who_page(domain):

    if is_domain(domain):
        url = "https://who.is/whois/{0}".format(domain)
        try:
            web_content = http_get(url)
            bs = BeautifulSoup(web_content, "html.parser")
            result = bs.find("div", class_="col-md-8")
            rule = re.compile('(\/tools\/)')
            finally_result = rule.sub('https://who.is//tools/',
                                      result.prettify())
            script_path = os.path.abspath(
                os.path.dirname(os.path.dirname(__file__)))
            finally_path = os.path.join(script_path,
                                        'output/{0}'.format("whois1.html"))
            sty = '<head><meta charset="UTF-8"><link href="../static/Bootstrap.css" rel="stylesheet" ' \
                  'type="text/css" /><link href="../static/main.css" rel="stylesheet" type="text/css" /></head>'
            out_page(finally_path, sty, finally_result)

        except Exception as e:
            print(e)