V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hard2reg
V2EX  ›  Python

用 Python 获取 LOL 真实下载地址

  •  
  •   hard2reg · 2016-04-29 01:24:08 +08:00 · 5143 次点击
    这是一个创建于 2920 天前的主题,其中的信息可能已经有所发展或是发生改变。

    新手第一帖,勿喷。。。

    
    # -*- coding:utf-8 -*-
    
    import requests
    from bs4 import BeautifulSoup
    
    def getlinks():
    	print('正在获取版本信息……')
    	r = requests.get('http://lol.qq.com/download.shtml')
    	r.encoding = 'gb2312'
    	soup = BeautifulSoup(r.text, 'html.parser')
    	info = soup.find('p', attrs={'class':'downinfo'}).text
    	ver = info[6:14].upper()
    	print('开始扫描真实下载地址……')
    	links = []
    	links.append('http://down.qq.com/lol/full/LOL_%s_FULL.exe' % ver)
    	p = 1
    	while True:
    		link = 'http://down.qq.com/lol/full/LOL_%s_FULL.7z.%03d' % (ver, p)
    		r = requests.head(link, allow_redirects=True)
    		if r.status_code == 200:
    			links.append(link)
    			p += 1
    		else:
    			break
    	print('以下是当前版本完整安装包的下载地址:')
    	for x in links:
    		print(x)
    	
    getlinks()
    
    
    7 条回复    2016-04-29 21:51:41 +08:00
    xustrive
        1
    xustrive  
       2016-04-29 09:03:47 +08:00
    @hard2reg 什么原理··· 网页中没找到 有 .7z 的连接···· 还是你分析的是客户端中的地址
    knightdf
        2
    knightdf  
       2016-04-29 09:25:28 +08:00
    F12 不谢。。。
    icy37785
        3
    icy37785  
       2016-04-29 09:27:35 +08:00
    @xustrive 他是拼接的地址,因为 lol 的真实下载地址就在这个目录,文件名也是用版本号命名的,所以在下载页抓取最新的版本号就可以了。至于这个目录怎么知道的,是从他的下载器里抓的。
    xustrive
        4
    xustrive  
       2016-04-29 09:38:47 +08:00
    @icy37785 酱紫··· 知道了 谢啦
    123s
        5
    123s  
       2016-04-29 10:42:27 +08:00
    下载器里面直接就有地址,呵呵。
    just4test
        6
    just4test  
       2016-04-29 16:02:51 +08:00
    还挺好玩的 哈哈哈哈
    不过每次我都是下载下载器然后解压找……
    hard2reg
        7
    hard2reg  
    OP
       2016-04-29 21:51:41 +08:00
    @123s 这样跟方便点啦。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2670 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:45 · PVG 12:45 · LAX 21:45 · JFK 00:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.