From 75369977ffcb8b1e89f107581bd8eefcf0c627b7 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 19 Oct 2021 08:51:08 +0800 Subject: [PATCH] bugfix --- appPublic/iplocation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/appPublic/iplocation.py b/appPublic/iplocation.py index e31a43d..c6a10a9 100644 --- a/appPublic/iplocation.py +++ b/appPublic/iplocation.py @@ -38,12 +38,16 @@ def ipaddress_com(ip): for tr in trs: th = tr.find_all('th')[0] td = tr.find_all('td')[0] + # print(th.contents, td.contents) if th.contents[0] == 'IP Latitude': d['lat'] = float(td.contents[0].split(' ')[0]) continue if th.contents[0] == 'IP Country': - print('ip country:contents[1]=', td.contents[1]) - d['country'] = td.contents[1].split('(')[0].strip() + # print('ip country:contents[-1]=', td.contents[-1]) + x = td.contents[-1].split('(')[0].strip() + while x[0] <= ' ' or x[0] >= chr(128): + x = x[1:] + d['country'] = x continue if th.contents[0] == 'IP Longitude': d['lon'] = float(td.contents[0].split(' ')[0])