修复搜索报错

This commit is contained in:
xmengnet 2021-05-15 18:59:06 +08:00 committed by GitHub
parent 036a8a4150
commit fa998cb97c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,14 +18,14 @@ class Ans(StdAns):
req = requests.get(
url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] ).json()
if req['results'] == []:
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&arg=' + self.parms[1]).json()
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=info&arg=' + self.parms[1]).json()
# print(req)
if req['resultcount'] > 0:
name = '包名:' + req['results'][0]['Name']
# pkgname = req['results'][0]['pkgname']
version = '版本:' + req['results'][0]['Version']
description = '描述:' + req['results'][0]['Description']
maintainer = '维护:' + req['results'][0]['Maintainer']
maintainer = '维护:' + str(req['results'][0]['Maintainer'])
numvotes = '投票:' + str(req['results'][0]['NumVotes'])
updatetime = req['results'][0]['LastModified']
updatetime = time.localtime(int(updatetime))