Python爬虫入门之查询ip地址

import requests

url = "http://m.ip138.com/ip.asp?ip="
IpAddress = input("Please input the ip address
")
try:
	r = requests.get(url+IpAddress)
	r.raise_for_status()
	r.encoding = r.apparent_encoding
	print(r.text[-400:-150])#截取有用的部分输出
except:
	print("ERROR")

原文地址:https://www.cnblogs.com/vocaloid01/p/9514164.html