update
This commit is contained in:
40
fetch_ips.py
40
fetch_ips.py
@@ -16,10 +16,6 @@ from pythonping import ping
|
|||||||
from requests_html import HTMLSession
|
from requests_html import HTMLSession
|
||||||
from retry import retry
|
from retry import retry
|
||||||
|
|
||||||
# GITHUB_URLS = [
|
|
||||||
# 'alive.github.com'
|
|
||||||
# ]
|
|
||||||
|
|
||||||
GITHUB_URLS = [
|
GITHUB_URLS = [
|
||||||
'alive.github.com', 'api.github.com', 'assets-cdn.github.com',
|
'alive.github.com', 'api.github.com', 'assets-cdn.github.com',
|
||||||
'avatars.githubusercontent.com', 'avatars0.githubusercontent.com',
|
'avatars.githubusercontent.com', 'avatars0.githubusercontent.com',
|
||||||
@@ -105,6 +101,18 @@ def get_best_ip(ip_list: list) -> str:
|
|||||||
return best_ip
|
return best_ip
|
||||||
|
|
||||||
|
|
||||||
|
@retry(tries=3)
|
||||||
|
def get_json(session: Any) -> Optional[list]:
|
||||||
|
url = 'https://raw.hellogithub.com/hosts.json'
|
||||||
|
try:
|
||||||
|
rs = session.get(url)
|
||||||
|
data = json.loads(rs.text)
|
||||||
|
return data
|
||||||
|
except Exception as ex:
|
||||||
|
print(f"get: {url}, error: {ex}")
|
||||||
|
raise Exception
|
||||||
|
|
||||||
|
|
||||||
@retry(tries=3)
|
@retry(tries=3)
|
||||||
def get_ip(session: Any, github_url: str) -> Optional[str]:
|
def get_ip(session: Any, github_url: str) -> Optional[str]:
|
||||||
url = f'https://www.ipaddress.com/site/{github_url}'
|
url = f'https://www.ipaddress.com/site/{github_url}'
|
||||||
@@ -133,16 +141,20 @@ def main(verbose=False) -> None:
|
|||||||
print('Start script.')
|
print('Start script.')
|
||||||
session = HTMLSession()
|
session = HTMLSession()
|
||||||
content = ""
|
content = ""
|
||||||
content_list = []
|
content_list = get_json(session)
|
||||||
for index, github_url in enumerate(GITHUB_URLS):
|
for item in content_list:
|
||||||
try:
|
content += item[0].ljust(30) + item[1] + "\n"
|
||||||
ip = get_ip(session, github_url)
|
# content_list = []
|
||||||
content += ip.ljust(30) + github_url + "\n"
|
# for index, github_url in enumerate(GITHUB_URLS):
|
||||||
content_list.append((ip, github_url,))
|
# try:
|
||||||
except Exception:
|
# # ip = get_ip(session, github_url)
|
||||||
continue
|
#
|
||||||
if verbose:
|
# content += ip.ljust(30) + github_url + "\n"
|
||||||
print(f'process url: {index + 1}/{len(GITHUB_URLS)}')
|
# content_list.append((ip, github_url,))
|
||||||
|
# except Exception:
|
||||||
|
# continue
|
||||||
|
# if verbose:
|
||||||
|
# print(f'process url: {index + 1}/{len(GITHUB_URLS)}')
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
return
|
return
|
||||||
|
|||||||
2
hosts
2
hosts
@@ -39,7 +39,7 @@
|
|||||||
13.107.213.51 vscode.dev
|
13.107.213.51 vscode.dev
|
||||||
|
|
||||||
|
|
||||||
# Update time: 2022-11-22T06:12:56+08:00
|
# Update time: 2022-11-22T08:54:55+08:00
|
||||||
# Update url: https://raw.hellogithub.com/hosts
|
# Update url: https://raw.hellogithub.com/hosts
|
||||||
# Star me: https://github.com/521xueweihan/GitHub520
|
# Star me: https://github.com/521xueweihan/GitHub520
|
||||||
# GitHub520 Host End
|
# GitHub520 Host End
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
[["140.82.114.25", "alive.github.com"], ["140.82.114.5", "api.github.com"], ["185.199.108.153", "assets-cdn.github.com"], ["185.199.109.133", "avatars.githubusercontent.com"], ["185.199.109.133", "avatars0.githubusercontent.com"], ["185.199.109.133", "avatars1.githubusercontent.com"], ["185.199.109.133", "avatars2.githubusercontent.com"], ["185.199.109.133", "avatars3.githubusercontent.com"], ["185.199.109.133", "avatars4.githubusercontent.com"], ["185.199.109.133", "avatars5.githubusercontent.com"], ["185.199.110.133", "camo.githubusercontent.com"], ["140.82.114.22", "central.github.com"], ["185.199.109.133", "cloud.githubusercontent.com"], ["140.82.113.10", "codeload.github.com"], ["140.82.113.22", "collector.github.com"], ["185.199.109.133", "desktop.githubusercontent.com"], ["185.199.109.133", "favicons.githubusercontent.com"], ["140.82.114.3", "gist.github.com"], ["54.231.236.105", "github-cloud.s3.amazonaws.com"], ["52.217.131.145", "github-com.s3.amazonaws.com"], ["52.217.166.25", "github-production-release-asset-2e65be.s3.amazonaws.com"], ["52.217.140.201", "github-production-repository-file-5c1aeb.s3.amazonaws.com"], ["52.217.72.20", "github-production-user-asset-6210df.s3.amazonaws.com"], ["192.0.66.2", "github.blog"], ["140.82.114.4", "github.com"], ["140.82.114.18", "github.community"], ["185.199.108.154", "github.githubassets.com"], ["151.101.65.194", "github.global.ssl.fastly.net"], ["185.199.111.153", "github.io"], ["185.199.109.133", "github.map.fastly.net"], ["185.199.108.153", "githubstatus.com"], ["140.82.114.26", "live.github.com"], ["185.199.109.133", "media.githubusercontent.com"], ["185.199.109.133", "objects.githubusercontent.com"], ["13.107.42.16", "pipelines.actions.githubusercontent.com"], ["185.199.109.133", "raw.githubusercontent.com"], ["185.199.109.133", "user-images.githubusercontent.com"], ["13.107.213.51", "vscode.dev"]]
|
|
||||||
Reference in New Issue
Block a user