LOL战绩查询工具
前言:刚开始学python,作为一个新手写了这么一个小玩意,本着大家一起学习的精神,分享出来,大佬看看笑笑就好;由于受易语言影响太深了,很多代码逻辑还是停留在易语言的风格上,举个栗子,需要叠加:E:i=i+1 p: i +=;代码预览载入e是空格,p是回车,很多很多~矫正太难了,慢慢习惯吧~再次强调一下昂,大佬看看就好,新手勿喷~import requests
from bs4 import BeautifulSoup
import re
from urllib import parse
header = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
}
findRegID = re.compile(r'data-val="(\d+)">(.*?)</div>')
findRegtpye = re.compile(r'data-val="\d+">(.*?)</div>')
def main():
cheack()
while True:
reg = input("请输入大区ID,比如是艾欧尼亚,请输入1 \n" )
if reg == "":
print("游戏大区不能为空")
pID = input("请输入游戏ID: \n")
if pID == "":
print("游戏ID不能为空!")
else:
print(pID,reg)
go(pID,reg)
#(response)
def go(pID,reg):
pID = parse.quote(pID, encoding="utf-8")
url = "https://www.lolhelper.cn/rank_lcu.php?gameid=" + pID + "&server="+str(reg)
print(url)
response = requests.get(url=url, headers=header)
response = response.text
soup = BeautifulSoup(response, 'lxml')
for item in soup.find_all("div", class_="main_item"):
res = item.text
res = res.replace('\n', '')
print(res)
#获取大区数据
def getReg():
url = 'https://www.lolhelper.cn'
response = requests.get(url = url,headers = header)
response = response.text
soup = BeautifulSoup(response,'lxml')
list = []
for item in soup.find_all('div',class_="option_sel_item"):
item = str(item)
reg = re.findall(findRegID,item)
list.append(reg)
# Name = re.findall(findRegName,item)
# print(Name)
#print(str(ID)+"."+Name)
return list
#检测展示大区数据
def cheack():
allReg = getReg()
allReglen = len(allReg)
print("发现大区%d个\n" % allReglen)
tupall=''
for item in allReg:
allRegCan = item
tup = allRegCan + "." + allRegCan
tupall = tupall +tup
print(tupall)
# print("发现大区%d个! " % allReglen)
if __name__ == "__main__":
main()
zqguang3708 发表于 2021-4-28 15:13
这不写着是https://www.lolhelper.cn/吗
应该不是lol官方的,第三方吧! Cool_Breeze 发表于 2021-4-28 15:04
是官方的网站吗?
这不写着是https://www.lolhelper.cn/吗 是官方的网站吗? 大佬666啊{:301_1000:} 能查云顶之弈的战绩吗? WeGame不是可以看吗 有没有查账号哪些大区有注册 和等级之类的 谢谢大佬!!!!! 官网提供的接口吧?
页:
[1]
2