2021-11-21 00:15:48 -08:00
|
|
|
|
import socket
|
|
|
|
|
import urllib.request
|
2021-11-21 00:49:49 -08:00
|
|
|
|
import urllib.parse
|
2021-11-21 00:15:48 -08:00
|
|
|
|
num = 1
|
|
|
|
|
|
2021-11-21 01:18:05 -08:00
|
|
|
|
try:
|
|
|
|
|
githubip = urllib.request.urlopen('https://api.github.com/meta')
|
|
|
|
|
githubip = str(githubip.read())
|
2022-02-06 23:42:52 -08:00
|
|
|
|
lines = urllib.request.urlopen('https://github.com/timqian/chinese-independent-blogs/raw/master/blogs-original.csv')
|
2022-02-07 00:00:44 -08:00
|
|
|
|
lines = lines.read().decode().splitlines()
|
2021-11-21 00:49:49 -08:00
|
|
|
|
except:
|
2022-02-07 00:00:44 -08:00
|
|
|
|
print('无法访问 Github,请检查网络。')
|
|
|
|
|
|
|
|
|
|
with open('gh-domains.txt', 'w') as f:
|
2021-11-21 00:49:49 -08:00
|
|
|
|
for line in lines[1:]:
|
2022-02-07 00:00:44 -08:00
|
|
|
|
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
|