Python 【解析库BeautifulSoup】

2021-02-10 04:15

阅读:408

YPE html>

标签:技术   HERE   www   port   alt   lin   doc   body   doctype   

一.简介

技术图片

二.安装命令

pip install beautifulsoup4

三.基本使用

1.基本使用

技术图片技术图片
html =‘‘‘
故事

这个是dromouse

Once upon a time there were three little sister; and their names were Localand Tillie; and they lived at the bottom of a well.

...

‘‘‘ from bs4 import BeautifulSoup soup = BeautifulSoup(html,lxml) #将网页以标准格式输出 soup.prettify() #输出title节点的内容 title = soup.title.string print(title)
View Code

2.节点选择器

技术图片技术图片
html =‘‘‘



故事

这个是dromouse

Once upon a time there were three little sister; and their names were Localand Tillie; and they lived at the bottom of a well.

...

‘‘‘ from bs4 import BeautifulSoup soup = BeautifulSoup(html,lxml) #将网页以标准格式输出 soup.prettify() #输出title节点的内容 title = soup.title.string #输出节点的名称 name = soup.title.name print(name)
View Code

 

Python 【解析库BeautifulSoup】

标签:技术   HERE   www   port   alt   lin   doc   body   doctype   

原文地址:https://www.cnblogs.com/Crown-V/p/12726000.html


评论


亲,登录后才可以留言!