python3.8
pycharm(2019.3.1):python IDE,python的集成开发环境
1、网页源码
r = requests.get(url)
tree = lxml.etree.HTML(r.text)
soup = bs4.Beautifulsoup(url, ‘lxml’)
到目前为止,通过阅读相关文本,感觉tree和soup中的内容是一样的。
2、进行信息提取
info0 = tree.xpath()
info1 = soup.find_all()
3、数据的保存与输出
for i in info:
(1)文档
i = info.tag[‘property’]
i = info.find()
f = open(‘file_name’, ‘a’)
f.write(i)
f.close()
(2)数据库(MySql)
connect = Connect()
curcor = connect.curcor()
# 执行sql语句操作
curcor.execute()
cursor.close()
connect.close()
(3)终端
print(i)
来源:CSDN
作者:安西宁
链接:https://blog.csdn.net/weixin_44754632/article/details/104646496