《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")
本文介绍了使用Python进行IP地址查询的方法,并展示了如何利用BeautifulSoup库解析网页HTML内容。通过具体示例,读者可以了解从发起HTTP请求到解析响应数据的全过程。
860

被折叠的 条评论
为什么被折叠?



