用 Python 获取 LOL 真实下载地址

2016-04-29 01:24:08 +08:00
 hard2reg

新手第一帖,勿喷。。。


# -*- 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()

5149 次点击
所在节点    Python
7 条回复
xustrive
2016-04-29 09:03:47 +08:00
@hard2reg 什么原理··· 网页中没找到 有 .7z 的连接···· 还是你分析的是客户端中的地址
knightdf
2016-04-29 09:25:28 +08:00
F12 不谢。。。
icy37785
2016-04-29 09:27:35 +08:00
@xustrive 他是拼接的地址,因为 lol 的真实下载地址就在这个目录,文件名也是用版本号命名的,所以在下载页抓取最新的版本号就可以了。至于这个目录怎么知道的,是从他的下载器里抓的。
xustrive
2016-04-29 09:38:47 +08:00
@icy37785 酱紫··· 知道了 谢啦
123s
2016-04-29 10:42:27 +08:00
下载器里面直接就有地址,呵呵。
just4test
2016-04-29 16:02:51 +08:00
还挺好玩的 哈哈哈哈
不过每次我都是下载下载器然后解压找……
hard2reg
2016-04-29 21:51:41 +08:00
@123s 这样跟方便点啦。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/275232

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX