forked from Mosiki/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_hosts.py
More file actions
42 lines (35 loc) · 878 Bytes
/
github_hosts.py
File metadata and controls
42 lines (35 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2019 Robin Wen <blockxyz@gmail.com>
#
# Distributed under terms of the MIT license.
import socket
import os
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def get_ip(host):
"""
Get ip of host.
"""
try:
host_ip = socket.gethostbyname(host)
return host_ip
except:
print("Unable to get IP of Hostname")
def main():
f = open('github_hosts.txt','w')
f.write("# GitHub Start\n")
f.close()
with open("github_domain.txt", "r") as ins:
for host in ins:
ip=get_ip(host.strip())
with open('github_hosts.txt', 'a') as result:
result.write(ip.strip('\n') + " " + host)
f = open('github_hosts.txt','a')
f.write("# GitHub End\n")
f.close()
if __name__ == "__main__":
main()