之前在百度经验上看到一篇的 怎么样关掉优酷和土豆等在线视频的缓冲广告的文章,简单实用了下发现果真可以用来屏蔽广告,出于好奇心,研究了下文章中方法一所用bat文件代码,发现其实就是在修改和备份hosts文件。
Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的IP地址,一旦找到,系统会立即打开对应网页,如果没有找到,则系统再会将网址提交DNS域名解析服务器进行IP地址的解析。
1、hosts中建立了ip地址和域名的映射关系,当请求指定域名的时候,windows先在hosts中查找是否存在映射关系,如果发现了映射ip,则直接使用此发送网络请求,如果没有找到对应关系,则使用DNS解析域名,解析后的ip再作为发送网络请求的目标ip
2、视频中的广告下载到电脑上也是需要发送ip请求的,存储视频广告的主机有他的ip和域名,并且dns可以将此域名解析为实际的ip,那么假如在hosts文件中存有与广告主机域名的ip映射,那么dns就不会解析这些广告主机域名,屏蔽广告的方法就是不把这些域名映射到真实的ip地址,而是映射到一个错误的ip地址,这样广告资源就下载不下来,在视频上就自然没有广告了。
127.0.0.1是回送地址,指本地机,一般用来测试使用。回送地址(127.x.x.x)是本机回送地址(Loopback Address),即主机IP堆栈内部的IP地址,主要用于网络软件测试以及本地机进程间通信,无论什么程序,一旦使用回送地址发送数据,协议软件立即返回,不进行任何网络传输。(摘自百度百科: 127.0.0.1)
hosts文件是没有后缀名的文件,是系统文件,可以通过记事本、ultraedit,notepad++等文本处理软件打开,系统中hosts文件存在于:C:\Windows\System32\drivers\etc目录下,最初始的内容是:
我从那篇文章上提取出包含的广告域名,做成hosts文件中的映射记录如下,要屏蔽广告的话只需在最后一行记录(127.0.0.1 localhost)后添加如下行后保存即可:
127.0.0.1 server1.adpolestar.net
127.0.0.1 mtips.xunlei.com
127.0.0.1 kkpgv.xunlei.com
127.0.0.1 statis.kankan.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 advstat.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 MSG1.client.xunlei.com
127.0.0.1 pubstat.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 mcfg.sandai.net
127.0.0.1 float.sandai.net
127.0.0.1 mpv.sandai.net
127.0.0.1 atm.youku.com
127.0.0.1 Fvid.atm.youku.com
127.0.0.1 html.atm.youku.com
127.0.0.1 valb.atm.youku.com
127.0.0.1 valc.atm.youku.com
127.0.0.1 valo.atm.youku.com
127.0.0.1 valp.atm.youku.com
127.0.0.1 valf.atm.youku.com
127.0.0.1 lstat.youku.com
127.0.0.1 speed.lstat.youku.com
127.0.0.1 urchin.lstat.youku.com
127.0.0.1 stat.youku.com
127.0.0.1 static.lstat.youku.com
127.0.0.1 vid.atm.youku.com
127.0.0.1 walp.atm.youku.com
127.0.0.1 g1.ykimg.com
127.0.0.1 g2.ykimg.com
127.0.0.1 g3.ykimg.com
127.0.0.1 g4.ykimg.com
127.0.0.1 comments.youku.com
127.0.0.1 e.stat.youku.com
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 adplay.tudou.com
127.0.0.1 stat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 pro.letv.com
127.0.0.1 afp.qiyi.com
127.0.0.1 track.cupid.qiyi.com
127.0.0.1 pic0.qiyipic.com
127.0.0.1 pic1.qiyipic.com
127.0.0.1 pic2.qiyipic.com
127.0.0.1 pic3.qiyipic.com
127.0.0.1 msg.video.qiyi.com
127.0.0.1 show.cupid.qiyi.com
127.0.0.1 api.cupid.qiyi.com
127.0.0.1 widget.weibo.com
127.0.0.1 a.htwisdom.com
127.0.0.1 vinfo.cdn.ppweb.com.cn
127.0.0.1 b.scorecardresearch.com
127.0.0.1 irs01.com
127.0.0.1 rec.inter.qiyi.com
127.0.0.1 score.video.qiyi.com
127.0.0.1 218.5.73.132
127.0.0.1 61.131.89.148
127.0.0.1 dcads.sina.com.cn
127.0.0.1 focusbaiduafp.allyes.com
127.0.0.1 adslvfile.qq.comadslvfile.qq.com
127.0.0.1 game0592.com
127.0.0.1 game.ad1111.com
127.0.0.1 server1.adpolestar.net
127.0.0.1 mtips.xunlei.com
127.0.0.1 kkpgv.xunlei.com
127.0.0.1 statis.kankan.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 advstat.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 MSG1.client.xunlei.com
127.0.0.1 pubstat.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 mcfg.sandai.net
127.0.0.1 float.sandai.net
127.0.0.1 mpv.sandai.net
127.0.0.1 atm.youku.com
127.0.0.1 Fvid.atm.youku.com
127.0.0.1 html.atm.youku.com
127.0.0.1 valb.atm.youku.com
127.0.0.1 valc.atm.youku.com
127.0.0.1 valo.atm.youku.com
127.0.0.1 valp.atm.youku.com
127.0.0.1 valf.atm.youku.com
127.0.0.1 lstat.youku.com
127.0.0.1 speed.lstat.youku.com
127.0.0.1 urchin.lstat.youku.com
127.0.0.1 stat.youku.com
127.0.0.1 static.lstat.youku.com
127.0.0.1 vid.atm.youku.com
127.0.0.1 walp.atm.youku.com
127.0.0.1 g1.ykimg.com
127.0.0.1 g2.ykimg.com
127.0.0.1 g3.ykimg.com
127.0.0.1 g4.ykimg.com
127.0.0.1 comments.youku.com
127.0.0.1 e.stat.youku.com
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 adplay.tudou.com
127.0.0.1 stat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 pro.letv.com
127.0.0.1 afp.qiyi.com
127.0.0.1 track.cupid.qiyi.com
127.0.0.1 pic0.qiyipic.com
127.0.0.1 pic1.qiyipic.com
127.0.0.1 pic2.qiyipic.com
127.0.0.1 pic3.qiyipic.com
127.0.0.1 msg.video.qiyi.com
127.0.0.1 show.cupid.qiyi.com
127.0.0.1 api.cupid.qiyi.com
127.0.0.1 widget.weibo.com
127.0.0.1 a.htwisdom.com
127.0.0.1 vinfo.cdn.ppweb.com.cn
127.0.0.1 b.scorecardresearch.com
127.0.0.1 irs01.com
127.0.0.1 rec.inter.qiyi.com
127.0.0.1 score.video.qiyi.com
127.0.0.1 218.5.73.132
127.0.0.1 61.131.89.148
127.0.0.1 dcads.sina.com.cn
127.0.0.1 focusbaiduafp.allyes.com
127.0.0.1 adslvfile.qq.comadslvfile.qq.com
127.0.0.1 game0592.com
127.0.0.1 game.ad1111.com
127.0.0.1 server1.adpolestar.net
127.0.0.1 mtips.xunlei.com
127.0.0.1 kkpgv.xunlei.com
127.0.0.1 statis.kankan.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 advstat.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 MSG1.client.xunlei.com
127.0.0.1 pubstat.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 mcfg.sandai.net
127.0.0.1 float.sandai.net
127.0.0.1 mpv.sandai.net
127.0.0.1 atm.youku.com
127.0.0.1 Fvid.atm.youku.com
127.0.0.1 html.atm.youku.com
127.0.0.1 valb.atm.youku.com
127.0.0.1 valc.atm.youku.com
127.0.0.1 valo.atm.youku.com
127.0.0.1 valp.atm.youku.com
127.0.0.1 valf.atm.youku.com
127.0.0.1 lstat.youku.com
127.0.0.1 speed.lstat.youku.com
127.0.0.1 urchin.lstat.youku.com
127.0.0.1 stat.youku.com
127.0.0.1 static.lstat.youku.com
127.0.0.1 vid.atm.youku.com
127.0.0.1 walp.atm.youku.com
127.0.0.1 g1.ykimg.com
127.0.0.1 g2.ykimg.com
127.0.0.1 g3.ykimg.com
127.0.0.1 g4.ykimg.com
127.0.0.1 comments.youku.com
127.0.0.1 e.stat.youku.com
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 adplay.tudou.com
127.0.0.1 stat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 pro.letv.com
127.0.0.1 afp.qiyi.com
127.0.0.1 track.cupid.qiyi.com
127.0.0.1 pic0.qiyipic.com
127.0.0.1 pic1.qiyipic.com
127.0.0.1 pic2.qiyipic.com
127.0.0.1 pic3.qiyipic.com
127.0.0.1 msg.video.qiyi.com
127.0.0.1 show.cupid.qiyi.com
127.0.0.1 api.cupid.qiyi.com
127.0.0.1 widget.weibo.com
127.0.0.1 a.htwisdom.com
127.0.0.1 vinfo.cdn.ppweb.com.cn
127.0.0.1 b.scorecardresearch.com
127.0.0.1 irs01.com
127.0.0.1 rec.inter.qiyi.com
127.0.0.1 score.video.qiyi.com
127.0.0.1 218.5.73.132
127.0.0.1 61.131.89.148
127.0.0.1 dcads.sina.com.cn
127.0.0.1 focusbaiduafp.allyes.com
127.0.0.1 adslvfile.qq.comadslvfile.qq.com
127.0.0.1 game0592.com
127.0.0.1 game.ad1111.com
127.0.0.1 server1.adpolestar.net
127.0.0.1 mtips.xunlei.com
127.0.0.1 kkpgv.xunlei.com
127.0.0.1 statis.kankan.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 advstat.xunlei.com
127.0.0.1 recommend.xunlei.com
127.0.0.1 cl.kankan.xunlei.com
127.0.0.1 MSG1.client.xunlei.com
127.0.0.1 pubstat.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 mcfg.sandai.net
127.0.0.1 float.sandai.net
127.0.0.1 mpv.sandai.net
127.0.0.1 atm.youku.com
127.0.0.1 Fvid.atm.youku.com
127.0.0.1 html.atm.youku.com
127.0.0.1 valb.atm.youku.com
127.0.0.1 valc.atm.youku.com
127.0.0.1 valo.atm.youku.com
127.0.0.1 valp.atm.youku.com
127.0.0.1 valf.atm.youku.com
127.0.0.1 lstat.youku.com
127.0.0.1 speed.lstat.youku.com
127.0.0.1 urchin.lstat.youku.com
127.0.0.1 stat.youku.com
127.0.0.1 static.lstat.youku.com
127.0.0.1 vid.atm.youku.com
127.0.0.1 walp.atm.youku.com
127.0.0.1 g1.ykimg.com
127.0.0.1 g2.ykimg.com
127.0.0.1 g3.ykimg.com
127.0.0.1 g4.ykimg.com
127.0.0.1 comments.youku.com
127.0.0.1 e.stat.youku.com
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 adplay.tudou.com
127.0.0.1 stat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 pro.letv.com
127.0.0.1 afp.qiyi.com
127.0.0.1 track.cupid.qiyi.com
127.0.0.1 pic0.qiyipic.com
127.0.0.1 pic1.qiyipic.com
127.0.0.1 pic2.qiyipic.com
127.0.0.1 pic3.qiyipic.com
127.0.0.1 msg.video.qiyi.com
127.0.0.1 show.cupid.qiyi.com
127.0.0.1 api.cupid.qiyi.com
127.0.0.1 widget.weibo.com
127.0.0.1 a.htwisdom.com
127.0.0.1 vinfo.cdn.ppweb.com.cn
127.0.0.1 b.scorecardresearch.com
127.0.0.1 irs01.com
127.0.0.1 rec.inter.qiyi.com
127.0.0.1 score.video.qiyi.com
127.0.0.1 218.5.73.132
127.0.0.1 61.131.89.148
127.0.0.1 dcads.sina.com.cn
127.0.0.1 focusbaiduafp.allyes.com
127.0.0.1 adslvfile.qq.comadslvfile.qq.com
127.0.0.1 game0592.com
127.0.0.1 game.ad1111.com