GitHub图片加载不出来解决方案(超详细图文教程)

前言

最近在访问GitHub时发现所有涉及到图片都加载失败,使人感觉极度不适;不将就是发现的源动力;有了之前《WordPress网站访问慢解决方案(超详细图文教程)》经验这次解决起来就顺利许多,下面是解决方案。

优化前:

  • 所有图片类型文件加载失败

优化后:

  • 所有图片类型文件正常加载

学完本教程你能得到什么

  • 排查网站加载资源失败解决思路
  • 使用软件获取网页数据进行格式化处理
  • 一颗不断探索的心
  • 一套可实时可落地的解决问题的套路

解决方案流程图

  • 流程图

问题&解决方案&验证

  • 问题(访问github,头像等图片加载失败)

  • 定位问题(图片资源域名访问不通)

    • 在google浏览器按F12,指定头像,找到头像url地址

    • 在cmd中 通过ping命令检查网络是通的,结果如下:

      //check头像资源域名
      ping avatars.githubusercontent.com
      正在 Ping github.map.fastly.net [151.101.228.133] 具有 32 字节的数据:
      来自 151.101.228.133 的回复: 字节=32 时间=175ms TTL=48
      来自 151.101.228.133 的回复: 字节=32 时间=154ms TTL=48
      来自 151.101.228.133 的回复: 字节=32 时间=154ms TTL=48
      来自 151.101.228.133 的回复: 字节=32 时间=153ms TTL=48
      
    • 查询域名映射ip对应关系网站 https://www.ipaddress.com

    • 可以看出是解析DNS出问题如下:

      域名 现在DNS解析对应ip 实际应该对应ip
      avatars.githubusercontent.com 151.101.228.133 199.232.96.133
  • 解决步骤

    • 在本机hosts(windows的hosts文件目录 C:\Windows\System32\drivers\etc\hosts)文件中增加头像域名和正确ip映射关系并保存

      199.232.96.133 avatars.githubusercontent.com
      

  • 在cmd中执行命令刷新本机DNS缓存

    ipconfig /flushdns
    

  • 进行验证,再次刷新github,发现头像可以正常加载,一下心情美丽许多

  • 当浏览项目时,发现有些项目中的图片还是加载失败

  • 再次通过google浏览器F12定位图片URL

  • 项目中的图片URL和头像URL对比;发现两者URL的二级域名一致,但是三级域名不同,又浏览一些项目发现每个项目中的文件地址中的三级域名都有可能不同

    头像域名 项目文件域名1 项目文件域名2 项目文件域名N
    avatars.githubusercontent.com camo.githubusercontent.com raw.githubusercontent.com
  • 第一直觉解决方案是:hosts中通过 * 全匹配二级域名去解决如下,不过实验以及查资料发现不hosts文件不支持这种规则

    //在hosts中用通配符来匹配二级域名下三级域名---不支持
    199.232.96.133 *.githubusercontent.com//在hosts中这样配置 只对githubusercontent.com 而对 avatars.githubusercontent.com 这些三级域名不生效
    199.232.96.133 githubusercontent.com
    
  • 程序猿的第一反应既然通配符这种形式行不通那就进行遍历;先在此贴出最终遍历后的hosts文件,大家可以直接用;下面会讲解如何获得内容

    199.232.96.133 scoopraw.githubusercontent.com
    199.232.96.133 avators.githubusercontent.com
    199.232.96.133 releases.githubusercontent.com
    199.232.96.133 2021-01-29-----2021-01-31github-releases.githubusercontent.com
    199.232.96.133 github-releases.githubusercontent.com
    199.232.96.133 avaters.githubusercontent.com
    199.232.96.133 ocame.githubusercontent.com
    199.232.96.133 github.comraw.githubusercontent.com
    199.232.96.133 vatars5.githubusercontent.com
    199.232.96.133 cano.githubusercontent.com
    199.232.96.133 vatars3.githubusercontent.com
    199.232.96.133 usr-image.githubusercontent.com
    199.232.96.133 war.githubusercontent.com
    199.232.96.133 avatar6.githubusercontent.com
    199.232.96.133 avatar7.githubusercontent.com
    199.232.96.133 clound.githubusercontent.com
    199.232.96.133 r-images.githubusercontent.com
    199.232.96.133 2017-12-14-----2020-12-22raw.githubusercontent.com
    199.232.96.133 raww.githubusercontent.com
    199.232.96.133 avastar0.githubusercontent.com
    199.232.96.133 ccraw.githubusercontent.com
    199.232.96.133 1h3.githubusercontent.com
    199.232.96.133 came.githubusercontent.com
    199.232.96.133 marketplace-images.githubusercontent.com
    199.232.96.133 desktep.githubusercontent.com
    199.232.96.133 eaw.githubusercontent.com
    199.232.96.133 rawxx.githubusercontent.com
    199.232.96.133 user.githubusercontent.com
    199.232.96.133 git.githubusercontent.com
    199.232.96.133 giraw.githubusercontent.com
    199.232.96.133 avatars56.githubusercontent.com
    199.232.96.133 image.githubusercontent.com
    199.232.96.133 windowsraw.githubusercontent.com
    199.232.96.133 ist.githubusercontent.com
    199.232.96.133 raw.githubraw.githubusercontent.com
    199.232.96.133 images.githubusercontent.com
    199.232.96.133 avatar3.githubusercontent.com
    199.232.96.133 avatar5.githubusercontent.com
    199.232.96.133 avatar4.githubusercontent.com
    199.232.96.133 avatar9.githubusercontent.com
    199.232.96.133 avatars10000000000000000000000000000.githubusercontent.com
    199.232.96.133 avatars40.githubusercontent.com
    199.232.96.133 avatars10000000000000000000000000000000000000000.githubusercontent.com
    199.232.96.133 avatars900.githubusercontent.com
    199.232.96.133 avatars10000.githubusercontent.com
    199.232.96.133 avatars1000.githubusercontent.com
    199.232.96.133 avatars80.githubusercontent.com
    199.232.96.133 avatars100000000.githubusercontent.com
    199.232.96.133 avatars500.githubusercontent.com
    199.232.96.133 codeload.githubusercontent.com
    199.232.96.133 house.githubusercontent.com
    199.232.96.133 httpsraw.githubusercontent.com
    199.232.96.133 gaw.githubusercontent.com
    199.232.96.133 user-image.githubusercontent.com
    199.232.96.133 actions.githubusercontent.com
    199.232.96.133 ser-images.githubusercontent.com
    199.232.96.133 awe.githubusercontent.com
    199.232.96.133 rawraw.githubusercontent.com
    199.232.96.133 w.githubusercontent.com
    199.232.96.133 rqw.githubusercontent.com
    199.232.96.133 coma.githubusercontent.com
    199.232.96.133 raws.githubusercontent.com
    199.232.96.133 rapid.githubusercontent.com
    199.232.96.133 avatar.githubusercontent.com
    199.232.96.133 www.avatars0.githubusercontent.com
    199.232.96.133 assets-cdn.githubusercontent.com
    199.232.96.133 cone.githubusercontent.com
    199.232.96.133 favicons.githubusercontent.com
    199.232.96.133 pkg.githubusercontent.com
    199.232.96.133 rwa.githubusercontent.com
    199.232.96.133 raw.raw.githubusercontent.com
    199.232.96.133 avatar0.githubusercontent.com
    199.232.96.133 avatar2.githubusercontent.com
    199.232.96.133 avatar1.githubusercontent.com
    199.232.96.133 1raw.githubusercontent.com
    199.232.96.133 row.githubusercontent.com
    199.232.96.133 github.githubusercontent.com
    199.232.96.133 cam.githubusercontent.com
    199.232.96.133 api.githubusercontent.com
    199.232.96.133 wwwcamo.githubusercontent.com
    199.232.96.133 www.camo.githubusercontent.com
    199.232.96.133 avatars99.githubusercontent.com
    199.232.96.133 avatars19.githubusercontent.com
    199.232.96.133 avatars16.githubusercontent.com
    199.232.96.133 avatars13.githubusercontent.com
    199.232.96.133 avatars12.githubusercontent.com
    199.232.96.133 avatars20.githubusercontent.com
    199.232.96.133 avatars17.githubusercontent.com
    199.232.96.133 avatars11.githubusercontent.com
    199.232.96.133 avatars15.githubusercontent.com
    199.232.96.133 avatars14.githubusercontent.com
    199.232.96.133 avatars18.githubusercontent.com
    199.232.96.133 avatars800.githubusercontent.com
    199.232.96.133 marketplace-screenshots.githubusercontent.com
    199.232.96.133 repository-images.githubusercontent.com
    199.232.96.133 gits.githubusercontent.com
    199.232.96.133 rraw.githubusercontent.com
    199.232.96.133 avatars.githubusercontent.com
    199.232.96.133 aw.githubusercontent.com
    199.232.96.133 avatars100.githubusercontent.com
    199.232.96.133 pipelines.actions.githubusercontent.com
    199.232.96.133 user-images.githubusercontent.com
    199.232.96.133 media.githubusercontent.com
    199.232.96.133 vatars0.githubusercontent.com
    199.232.96.133 render.githubusercontent.com
    199.232.96.133 www.raw.githubusercontent.com
    199.232.96.133 avatars8.githubusercontent.com
    199.232.96.133 avatars7.githubusercontent.com
    199.232.96.133 avatars9.githubusercontent.com
    199.232.96.133 avatars6.githubusercontent.com
    199.232.96.133 avatars5.githubusercontent.com
    199.232.96.133 avatars10.githubusercontent.com
    199.232.96.133 avatars4.githubusercontent.com
    199.232.96.133 gist.githubusercontent.com
    199.232.96.133 www.githubusercontent.com
    199.232.96.133 desktop.githubusercontent.com
    199.232.96.133 avatars3.githubusercontent.com
    199.232.96.133 avatars0.githubusercontent.com
    199.232.96.133 avatars1.githubusercontent.com
    199.232.96.133 cloud.githubusercontent.com
    199.232.96.133 camo.githubusercontent.com
    199.232.96.133 githubusercontent.com
    199.232.96.133 avatars2.githubusercontent.com
    199.232.96.133 raw.githubusercontent.com
    
  • 将这个全的内容放入到hosts文件中

  • 通过cmd命令(ipconfig /flushdns)重新刷新本机DNS

  • 再次验证,发现图片都能正常加载,这次真的是爽歪歪

  • 获取三级域名及形成符合hosts文件格式文件内容

    • 需要知道GitHub资源文件二级域名(githubusercontent.com)都有哪些三级域名

    • 在一个通过二级域名查其含有三级域名网站进行查询https://chaziyu.com 发现共有124条子域名

    • 随机抽查几个三级域名去 域名对应ip查询( https://www.ipaddress.com) 发现对应ip都是199.232.96.133

    • 这么多二级域名怎么给转换成hosts文件格式那?肯定不能一个一个粘贴

      //hosts格式:ip 三级域名
      199.232.96.133 scoopraw.githubusercontent.com
      199.232.96.133 avators.githubusercontent.com
      ·····
      
    • 想到之前用的一个八爪鱼采集器可以获取网页数据的软件,可以将这些三级域名数据爬取到excel中

      • 输入需要爬取网页地址

      • 自动识别网页

      • 生成采集设置

      • 进行数据采集

      • 采集完成后导出excel

    • 在excel中删除无用列并将 子域名列124条数据粘贴到文本编辑器中(在此以Sublime为例)

    • 在Sublime中进行列选择在其前面增加统一的ip形成新的hosts文件

总结

  • 欢迎大家访问我的GitHub并start
  • 本人将持续不断的在GitHub上输出优秀成系列的代码

GitHub图片加载不出来解决方案(超详细图文教程)相关推荐

  1. 使用VScode + PicGo 写markdown 以及github图片加载不出的问题

    目录 使用VScode + PicGo 写markdown GitHub图片加载慢/不出的问题 使用VScode + PicGo 写markdown PicGo在vscode中相当于把你剪贴板图片上传 ...

  2. CENTOS 7 踢用户_从零学ELK系列(三):Centos安装Docker(超详细图文教程)

    CSDN博客地址(关注,点赞) 人工智能推荐 GitHub(Star,Fork,Watch) [前言] 为了更加真实的模拟生产部署环境,不仅需要Linux环境支持,而且ELK需要在不同的机器上部署:再 ...

  3. 剪映导出SRT字幕超详细图文教程

    剪映导出SRT字幕超详细图文教程 视频的字幕是制作视频的过程当中一个很麻烦的事情. 不仅要使得字幕和人声出现的时间匹配,还要校对错别字,删减字幕,增加字幕等繁琐的操作.在以往为视频添加字幕的操作中,有 ...

  4. 从零学ELK系列(十一):SpringBoot项目接入ELK超级版(超详细图文教程)

    前言 之前在<从零学ELK系列(十):SpringBoot项目接入ELK升级版(超详细图文教程)>中演示了SpringBoot项目接入ELK请求记录及优化,本次针对于未知异常通过拦截进行记 ...

  5. 从零学ELK系列(三):Centos安装Docker(超详细图文教程)

    [前言] 为了更加真实的模拟生产部署环境,不仅需要Linux环境支持,而且ELK需要在不同的机器上部署:再重新装几台虚拟机?本地资源不支持,于是乎想到了Docker:今天在上次的Linux系统(< ...

  6. 从零学ELK系列(四):Docker安装Elasticsearch(超详细图文教程)

    [前言] 为了更加真实的模拟生产部署环境,在上次的Docker环境中(<Centos安装Docker(超详细图文教程)>)中安装了Elasticsearch把步骤记录下来,一是方便自己以后 ...

  7. 从零学ELK系列(六):Docker安装Logstash(超详细图文教程)

    [前言] 为了更加真实的模拟生产部署环境,在上次的Docker环境中(<Docker安装kibana(超详细图文教程)>)中安装了kibana,本次我们将安装日志清洗组件---logsta ...

  8. 从零学ELK系列(七):Centos安装Filebeat(超详细图文教程)

    [前言] 为了更加真实的模拟生产部署环境,在上次的Docker环境中(<Docker安装Logstash(超详细图文教程)>)中安装了Logstash,本次我们将安装日志收集组件---Fi ...

  9. 传奇单机架设超详细图文教程

    传奇单机架设超详细图文教程--GOM引擎 1.安装DBC,配置引擎 2.上传列表,配置登录器 3.安装客户端,解压补丁 4.登录游戏 无论你是想要架设单机自己玩还是测试版本,今天的这篇单机架设教程都能 ...

  10. 如何自己开传奇单机架设超详细图文教程

    如何自己成为传奇,如何自己搭建传奇非官服,首先下载传奇服务器后,会有两个压缩包,一个用于服务器,一个用于游戏补丁文件 传奇单机设置-GOM引擎的超详细图文教程 版本文件包含.exe,以上文件都不起作用 ...

最新文章

  1. 2021年大数据Spark(二十):Spark Core外部数据源引入
  2. git使用,Git的skil-map
  3. mysql select 缓存_mysql select缓存机制使用详解
  4. python内置数据结构_Python基础知识2-内置数据结构(下)
  5. 寻求神谕的词语:谈海日寒诗集《空山集》
  6. 启动nginx服务报错Job for nginx.service failed because the control process exited with error code.
  7. druid加密mysql_Druid 数据库用户密码加密 代码实现
  8. mysql存储过程 等于_mysql存储过程字符串等于
  9. LeetCode(283)——移动零(JavaScript)
  10. 联想y50更换固态硬盘_旧笔记本电脑更换固态硬盘
  11. getTime()的兼容性(ios)
  12. CRMEBv3.1微商城源码,含小程序商城,公众号商城,H5商城
  13. 这6点解释了罗永浩为什么要卖艺
  14. 联通的G网和C网分别是什么意思?
  15. CUDA编程实现求解单源Bellman-Ford最短 路径算法
  16. 如何做一个优秀的数据分析项目?
  17. word中表格出现断线的问题
  18. 计算机总是提示网络电缆没有插,网络电缆没有插好原因与解决方法【图文教程】...
  19. SPSS Modeler建立ODBC数据源使用数据库文件
  20. java 手电筒_《SystemUI》限制低电量打开手电筒

热门文章

  1. 解析几何 直线与平面 直线与平面(1.2)
  2. Linux系统设置屏幕分辨率
  3. 数学建模-模糊综合评价法(评价模型)
  4. MongoDB数据导入 JSON
  5. spring整合WebService入门详解
  6. 23.方法重写的本质与虚方法表的使用
  7. 收到华为offer后的阶段性总结
  8. Separating Pebbles数学,暴力
  9. 如何建设研发部门体系,理清责任和关系
  10. win10扩展EFI分区