import requests
from bs4 import BeautifulSoup
def queryIpAddress(ipaddress):
# reaponse = requests.get("https://ip.cn/index.php?ip={}".format(ipaddress))
# soup = BeautifulSoup(reaponse.content, 'lxml')
# a = soup.find('div', attrs={'class': 'well'})
# address = a.find_all('code')[1].text
# 以上4行代码是获取中文的地理位置
reaponse = requests.get("https://ip.cn/index.php?ip={}".format(ipaddress), timeout=10)
soup = BeautifulSoup(reaponse.content, 'lxml')
a = soup.find('div', attrs={'class': 'well'})
b = a.find_all('p')[3].text
address = b.replace("GeoIP: ", "")
# 以上返回 英文或拼音的地理位置
return address