mirror of
https://github.com/saveweb/is-github-page.git
synced 2024-09-19 08:35:29 -07:00
精简
This commit is contained in:
parent
fd3081af77
commit
7892a17bfa
40
main.py
40
main.py
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user