【爬虫练习】

【练习一】爬取iot门户网站中部分页面信息:

import requests 
from bs4 import BeautifulSoup

url='http://www.ioteis.com/Stewardship.html'

response_data=requests.get(url)
response_data.encoding='utf-8'

#把html页面进行解析
soup=BeautifulSoup(response_data.text,'lxml')

#分析发现内容放在content1下面的div中
for hbgj in soup.select(".content1 "):
	title=hbgj.select("div.title1 a")[0].text
	content=hbgj.select('div.ptext')[0].text
	print("标题为:{},内容为:{}".format(title,content))

  

【练习二】

原文地址:https://www.cnblogs.com/benpao1314/p/11410849.html