github访问太慢解决方案
问题描述
打开github网页太慢
问题原因
被墙,导致DNS无法访问,实际上通过配置本地域名到IP的映射可以避免查询DNS服务器,从而加快速度。
为了验证确实是DNS的问题,请前往站长之家DNS查询,可以看见很多DNS服务器都没有。
一般Github的访问有两部分:主站的访问和二级域名的资源加载(比如样式文件等)
一般Github加载缓慢,主要是 assets-cdn.github.com、avatars0.githubusercontent.com 以及 avatars1.githubusercontent.com 三个域名的解析问题。(国内很多地方解析不了)
为了提高速度,可以使用HOSTS加速对Github的域名解析。
解决方法
windows C:\Windows\System32\drivers\etc\hosts
linux /private/etc/hosts
修改hosts主机映射文件:
添加github一系列网址的IP地址、域名映射
原理就是:当我们访问github时,那些域名什么的就不需要去DNS服务器上询问了,直接从本地HOST文件中获得。
但是github域名所对应IP好像是随时间变化的,挨个查询太麻烦,来个脚本
先建立一个域名列表haha.txt,下面列表中的gist.github.com是代码片功能,被墙得死死地。无论如何打不开。
github.com
assets-cdn.github.com
avatars0.githubusercontent.com
avatars1.githubusercontent.com
documentcloud.github.com
gist.github.com
help.github.com
nodeload.github.com
raw.github.com
status.github.com
training.github.com
github.io
然后用python语言使用requests+beautifulsoup制作一个小爬虫
import requests
from bs4 import BeautifulSoup
for i in open("haha.txt"):
url = "http://ip.chinaz.com/" + i.strip()
resp = requests.get(url)
soup=BeautifulSoup(resp.text)
x=soup.find(class_="IcpMain02")
x=x.find_all("span",class_="Whwtdhalf")
print(x[5].string.strip(),i.strip())
最终得到所要结果
192.30.253.113 github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 avatars0.githubusercontent.com
151.101.100.133 avatars1.githubusercontent.com
151.101.100.133 documentcloud.github.com
8.7.198.45 gist.github.com
151.101.100.133 help.github.com
192.30.253.121 nodeload.github.com
151.101.100.133 raw.github.com
174.129.214.132 status.github.com
151.101.100.133 training.github.com
23.235.33.133 github.io
关闭浏览器,重新打开,就能体验到飞一般的感觉 !
为了简单,可以通过Python直接更改HOSTS文件,不用手动更改。
s = """
github.com
assets-cdn.github.com
avatars0.githubusercontent.com
avatars1.githubusercontent.com
documentcloud.github.com
help.github.com
nodeload.github.com
raw.github.com
status.github.com
training.github.com
github.io
"""
import requests
from bs4 import BeautifulSoup
ans = []
for i in s.split():
url = "http://ip.chinaz.com/" + i.strip()
resp = requests.get(url)
soup = BeautifulSoup(resp.text)
x = soup.find(class_="IcpMain02")
x = x.find_all("span", class_="Whwtdhalf")
x = "%s %s" % (x[5].string.strip(), i.strip())
print(x)
ans.append(x)
hosts = r"C:\Windows\System32\drivers\etc\hosts"
with open(hosts, "r") as f:
content = [i for i in f.readlines() if i.startswith("#")]
content.extend(ans)
with open(hosts, "w") as f:
f.write("\n".join(content))
github访问太慢解决方案的更多相关文章
- github访问很慢解决方案
首先要解决的就是这个访问速度的问题: 获取Github相关网站的ip 访问https://www.ipaddress.com,拉下来,找到页面中下方的“IP Address Tools – Quick ...
- 解决www.github.com访问太慢的问题
解决www.github.com访问太慢的问题 使用www.github.com的过程中,有时候打开会特别的慢,原因github.com的域名被一堵伟大的墙挡在了外面.但是我们可以通过修改本机的hos ...
- 【亲测有效】Github无法访问或者访问速度的解决方案
我相信,很多朋友都遇到了 Github 访问速度过慢的问题,我也是在此记下笔记,方便以后拿来使用. 第一步.修改Hosts 通过问题的搜索了解到 github 访问很慢一般通过修改 hosts 文件解 ...
- github 入门教程之 github 访问速度太慢怎么办
github 是全世界最流行的开源项目托管平台,其代表的开源文化从根本上改变了软件开发的方式. 基本上所有的需求都能从 github 上或多或少找到现成的实现方案,再也不用重头开始造轮子而是自定义轮子 ...
- 加速Github访问
Github 仓库的数据传输很慢,甚至可能导致仓库拉取失败.例如: remote: Enumerating objects: , done. remote: Counting objects: % ( ...
- 远程客户端连接MysqL数据库太慢解决方案
远程客户端连接MysqL数据库太慢解决方案局域网客户端访问mysql 连接慢问题解决. cd /etc/mysql vi my.conf [mysqld] skip-name-resolve 此选项禁 ...
- 转: 解决Github访问超慢问题
转自:http://zengrong.net/post/2092.htm 解决Github访问超慢问题 Github is so slowly. 这段时间访问 github 都非常慢,google了一 ...
- 转: Github访问慢解决办法
from: https://yq.aliyun.com/articles/36744 Github访问慢解决办法 zxiaofan 2016-04-20 17:25:00 浏览2156 评论0 摘 ...
- 解决Github访问超慢问题[自己留档]
解决Github访问超慢问题 Github is so slowly. 这段时间访问 github 都非常慢,google了一下发现是github某个CDN被伟大的墙屏蔽所致. 出问题的应该是这个CD ...
随机推荐
- 用Python语言写Hadoop MapReduce程序Writing an Hadoop MapReduce Program in Python
In this tutorial I will describe how to write a simple MapReduce program for Hadoop in the Python pr ...
- Html5 中获取镜像图像 - 解决 WebGL 中纹理倒置问题
Html5 中获取镜像图像 - 解决 WebGL 中纹理倒置问题 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致& ...
- OpenCV学习(35) OpenCV中的PCA算法
PCA算法的基本原理可以参考:http://www.cnblogs.com/mikewolf2002/p/3429711.html 对一副宽p.高q的二维灰度图,要完整表示该图像,需要m = ...
- 如何处理wordpress首页不显示指定分类文章
如何实现wordpress首页不显示指定分类文章,要实现这一步,首先必须找到需要屏蔽的该目录的id,那么如何查看wordpress的分类id呢?有两种方法: 通过wordpress后台查看分类的ID ...
- 以ScaleIO 1.30为后端存储运行微软服务器软件SQL Server 2014, SharePoint 2013, Exchange 2013的解决方案
EMC新发布了以ScaleIO 1.30为后端存储来运行SQL, SharePoint, Exchange的解决方案白皮书. 下面的页面中有简要的介绍和整篇文档PDF的下载. https://co ...
- Bridge 桥接模式 MD
桥接模式 简介 将抽象部分与实现部分分离,使它们都可以独立的变化. 业务抽象角色引用业务实现角色,或者说业务抽象角色的部分实现是由业务实现角色完成的 Bridge模式基于类的最小设计原则,通过使用封装 ...
- tp 生成静态页
$this->fetch()返回的是html 可以直接写入到HTML文件内生成静态页
- 我对REST的理解
1:rest的由来 REST即表述性状态传递(英文:Representational State Transfer,简称REST) 通俗点说:资源在网络中以某种表现形式进行状态转移. 源于REST之父 ...
- Solr添加SolrDocument报错
今天写了一个solr入库接口,使用了SolrServer.addBean接口,结果报错:Caused by: org.apache.solr.client.solrj.impl.HttpSolrSer ...
- UVALive 2949 Elevator Stopping Plan(二分 + 贪心)
ZSoft Corp. is a software company in GaoKe Hall. And the workers in the hall are very hard-working. ...