Advertisement
cuteSquirrel

Create DNS dictionary from URL

Dec 1st, 2022
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import urllib.request
  2.  
  3. url = "https://admin.quic.cloud/api/dnslist"
  4. contents = urllib.request.urlopen(url).read().decode('utf-8')
  5.  
  6. # 得到每一行
  7. str_contents = contents.splitlines()
  8.  
  9. # 用網頁上的 空白 短 空白 切割每一行
  10. parsing = lambda s:s.split(' - ')
  11.  
  12. # DNS_dict: python dictionary
  13. # DNS名字當作 key
  14. # IP位置當作 value
  15. DNS_dict = dict( [ *map(parsing, str_contents) ] )
  16.  
  17. print( DNS_dict )
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement