Python Gets the IP, registration time, expiration time of the domain name

Source: Internet
Author: User

Import requestsimport jsonimport asyncioimport aiohttpfrom bs4 import beautifulsoupimport datetimeresult1={"Baidu": {" Domain_Name ":" www.baidu.com "}}result2=[]async def get_title (k,i): If ' http://' in i:i = ' i[7 '] url = ' http://seo.chinaz.c om/?q={} '. Format (i) async with aiohttp. Clientsession () as Session:async with Session.get (URL) as Resp:text = await resp.text () soup = beautifulsoup (text, ' HTML . Parser ') Try:ret_time = Soup.find (' div ' class_= ' w97-0 brn col-hint02 pl0 '). Text.split (' in ') [1].split (', ') CTime = ret_t Ime[0][:-1].replace (' Year ', '-'). Replace (' month ', '-') + ' 00:00 ' etime = Ret_time[1].split (' as ') [1][:-2].replace (' Year ', '-'). Replace (' month ', '-') + ' 00:00 ' Try:lis = soup.find (' div ', class_= ' brn ipmw '). Text lis_ip = (lis[3:].split (' [')) [0] except Ex Ception as E:print ("No IP", e) lis_ip = ' 0.0.0.0 ' a = {k:{' name ': I, ' IP ': lis_ip, ' CTime ': CTime, ' etime ': etime, ' comment ': k}} Result2.append (a) except Exception as E:print ("Domain not Found", e) b = {k:{' name ': I, ' IPD ': ' 0.0.0.0 ', ' CTime ': Datetime.datetime.now(). Strftime ('%y-%m-%d%h:%m '), ' ETime ':d atetime.datetime.now (). Strftime ('%y-%m-%d%h:%m '), ' comment ': k}} Result2.append (b) loop = Asyncio.get_event_loop () Fun_list = (Get_title (k=k,i=n) for index, I in enumerate (RESULT1) for K, V In I.items () for M, N in V.items ()) Loop.run_until_complete (Asyncio.gather (*fun_list)) print (RESULT2)

Python Gets the IP, registration time, expiration time of the domain name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.