ToKeiChun

IPs Extractor from Files

Apr 20th, 2021 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. # this tools can be used to extracting ips from a files that contain other string apart from ip
  2. import re
  3.  
  4. def extactip():
  5.     opener = open('SAMPLE.txt', 'r').read()
  6.     getips = re.findall(r'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b', opener)
  7.     for i in getips:
  8.         print(i)
  9.         open('IPs-List.txt', 'a').write(i + "\n")
  10. extactip()
Add Comment
Please, Sign In to add comment