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