import requests import time
url = "https://my.ip.cn/api/index?ip=&type=0"
headers = { ":authority": "my.ip.cn", ":method": "GET", ":path": "/api/index?ip=&type=0", ":scheme": "https", "accept": "application/json, text/javascript, */*; q=0.01", "accept-encoding": "gzip, deflate, br", "accept-language": "en-CN,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,en-US;q=0.6,zh-TW;q=0.5,ja;q=0.4", "cookie":"__cfduid=dfd9a8ad770a7d54ed934a6adb02390651607854807; INIT_IP_INFO=%E4%B8%AD%E5%9B%BD++%E9%BB%91%E9%BE%99%E6%B1%9F%E7%9C%81+%E5%93%88%E5%B0%94%E6%BB%A8%E5%B8%82+%E8%81%94%E9%80%9A", "referer": "https://my.ip.cn/", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36", "x-requested-with": "XMLHttpRequest" } Result = requests.get(url).json()
print(Result['ip'])
print(Result['address']) City = Result['address'].split(" ")[-2]
|