update
This commit is contained in:
60
fetch_ips.py
60
fetch_ips.py
@@ -17,26 +17,30 @@ from requests_html import HTMLSession
|
||||
from retry import retry
|
||||
|
||||
GITHUB_URLS = [
|
||||
'alive.github.com', 'api.github.com', 'assets-cdn.github.com',
|
||||
'avatars.githubusercontent.com', 'avatars0.githubusercontent.com',
|
||||
'avatars1.githubusercontent.com', 'avatars2.githubusercontent.com',
|
||||
'avatars3.githubusercontent.com', 'avatars4.githubusercontent.com',
|
||||
'avatars5.githubusercontent.com', 'camo.githubusercontent.com',
|
||||
'central.github.com', 'cloud.githubusercontent.com', 'codeload.github.com',
|
||||
'collector.github.com', 'desktop.githubusercontent.com',
|
||||
'favicons.githubusercontent.com', 'gist.github.com',
|
||||
'github-cloud.s3.amazonaws.com', 'github-com.s3.amazonaws.com',
|
||||
'github-production-release-asset-2e65be.s3.amazonaws.com',
|
||||
'github-production-repository-file-5c1aeb.s3.amazonaws.com',
|
||||
'github-production-user-asset-6210df.s3.amazonaws.com', 'github.blog',
|
||||
'github.com', 'github.community', 'github.githubassets.com',
|
||||
'github.global.ssl.fastly.net', 'github.io', 'github.map.fastly.net',
|
||||
'githubstatus.com', 'live.github.com', 'media.githubusercontent.com',
|
||||
'objects.githubusercontent.com', 'pipelines.actions.githubusercontent.com',
|
||||
'raw.githubusercontent.com', 'user-images.githubusercontent.com',
|
||||
'vscode.dev'
|
||||
'alive.github.com'
|
||||
]
|
||||
|
||||
# GITHUB_URLS = [
|
||||
# 'alive.github.com', 'api.github.com', 'assets-cdn.github.com',
|
||||
# 'avatars.githubusercontent.com', 'avatars0.githubusercontent.com',
|
||||
# 'avatars1.githubusercontent.com', 'avatars2.githubusercontent.com',
|
||||
# 'avatars3.githubusercontent.com', 'avatars4.githubusercontent.com',
|
||||
# 'avatars5.githubusercontent.com', 'camo.githubusercontent.com',
|
||||
# 'central.github.com', 'cloud.githubusercontent.com', 'codeload.github.com',
|
||||
# 'collector.github.com', 'desktop.githubusercontent.com',
|
||||
# 'favicons.githubusercontent.com', 'gist.github.com',
|
||||
# 'github-cloud.s3.amazonaws.com', 'github-com.s3.amazonaws.com',
|
||||
# 'github-production-release-asset-2e65be.s3.amazonaws.com',
|
||||
# 'github-production-repository-file-5c1aeb.s3.amazonaws.com',
|
||||
# 'github-production-user-asset-6210df.s3.amazonaws.com', 'github.blog',
|
||||
# 'github.com', 'github.community', 'github.githubassets.com',
|
||||
# 'github.global.ssl.fastly.net', 'github.io', 'github.map.fastly.net',
|
||||
# 'githubstatus.com', 'live.github.com', 'media.githubusercontent.com',
|
||||
# 'objects.githubusercontent.com', 'pipelines.actions.githubusercontent.com',
|
||||
# 'raw.githubusercontent.com', 'user-images.githubusercontent.com',
|
||||
# 'vscode.dev'
|
||||
# ]
|
||||
|
||||
HOSTS_TEMPLATE = """# GitHub520 Host Start
|
||||
{content}
|
||||
|
||||
@@ -54,13 +58,16 @@ def write_file(hosts_content: str, update_time: str) -> bool:
|
||||
if os.path.exists(output_doc_file_path):
|
||||
with open(output_doc_file_path, "r") as old_readme_fb:
|
||||
old_content = old_readme_fb.read()
|
||||
old_hosts = old_content.split("```bash")[1].split("```")[0].strip()
|
||||
old_hosts = old_hosts.split("# Update time:")[0].strip()
|
||||
hosts_content_hosts = hosts_content.split("# Update time:")[
|
||||
0].strip()
|
||||
if old_hosts == hosts_content_hosts:
|
||||
print("host not change")
|
||||
return False
|
||||
if old_content:
|
||||
old_hosts = old_content.split("```bash")[1].split("```")[0].strip()
|
||||
old_hosts = old_hosts.split("# Update time:")[0].strip()
|
||||
hosts_content_hosts = hosts_content.split("# Update time:")[
|
||||
0].strip()
|
||||
if old_hosts == hosts_content_hosts:
|
||||
print("host not change")
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
with open(template_path, "r") as temp_fb:
|
||||
template_str = temp_fb.read()
|
||||
@@ -123,6 +130,8 @@ def get_ip(session: Any, github_url: str) -> Optional[str]:
|
||||
|
||||
|
||||
def main(verbose=False) -> None:
|
||||
if verbose:
|
||||
print('Start script.')
|
||||
session = HTMLSession()
|
||||
content = ""
|
||||
content_list = []
|
||||
@@ -147,6 +156,7 @@ def main(verbose=False) -> None:
|
||||
write_json_file(content_list)
|
||||
if verbose:
|
||||
print(hosts_content)
|
||||
print('End script.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user