This commit is contained in:
yzqzss 2022-02-07 16:00:44 +08:00
parent fd3081af77
commit 7892a17bfa

40
main.py
View File

@ -7,25 +7,25 @@ try:
githubip = urllib.request.urlopen('https://api.github.com/meta')
githubip = str(githubip.read())
lines = urllib.request.urlopen('https://github.com/timqian/chinese-independent-blogs/raw/master/blogs-original.csv')
lines = str(lines.read())
lines = lines.splitlines()
lines = lines.read().decode().splitlines()
print(lines)
except:
print('无法访问GitHub请检查网络。')
else:
with open('gh-domains.txt', 'w') as f:
print('无法访问 Github请检查网络。')
with open('gh-domains.txt', 'w') as f:
for line in lines[1:]:
print(num)
num = num + 1
line = line.replace(" ", "").split(',')
res = urllib.parse.urlparse(line[1])
domain = res.netloc
try:
ip = socket.gethostbyname(domain)
ip = ip.split('.')
ip_head = ip[0]+'.'+ip[1]+'.'+ip[2]
isfind = githubip.find(ip_head)
if isfind != -1 :
f.write(domain+"\n")
print(domain+" 是GH-Pages!")
except:
continue
print(num)
num = num + 1
line = line.replace(" ", "").split(',')
res = urllib.parse.urlparse(line[1])
domain = res.netloc
try:
ip = socket.gethostbyname(domain)
ip = ip.split('.')
ip_head = ip[0]+'.'+ip[1]+'.'+ip[2]
isfind = githubip.find(ip_head)
if isfind != -1 :
f.write(domain+"\n")
print(domain+" 是GH-Pages!")
except:
continue