《2018年5月24日》
标题:IP地址查询,BeautifulSoup库安装;
内容:
1.IP地址查询:
#Requests.V1
import requests
url ="http://www.ip138.com/ips138.asp?ip="
try:
r =requests.get(url +'202.204.80.112')
r.raise_for_status()
r.encoding =r.apparent_encoding
print(r.text[-500:])
except:
print("爬取失败")
2.网页html解析:
from bs4 import BeautifulSoup
soup =BeautifulSoup('<p>data</p>',"html.parser")