1.主要内容
soup=BeatifuleSoup(response.text,'html.parser') , soup的数据结构
find=soup.find_all(),find的数据结构
1.代码
在python IDE 运行结果
>>> import requests
>>> from bs4 import BeautifulSoup
>>> res=requests.get('https://www.baidu.com/')
>>> res.encoding='utf-8'
>>> soup=BeautifulSoup(res.text,'html.parser')
>>> type(soup)
<class 'bs4.BeautifulSoup'>
>>> print(soup)
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta content="text/html;charset=utf-8" http-equiv="content-type"/>…………………………………………………………</html>
>>>find=soup.find_all('a')
>>>type(find)
<class 'bs4.element.ResultSet'>
print(find)
[<a class="mnav" href="h

本文详细介绍了使用BeautifulSoup解析HTML时,`soup=BeautifulSoup(response.text,'html.parser')`和`soup.find_all()`返回的数据结构。内容包括节点的概念、不同类型节点的属性和文本,以及如何通过find_all()进行数据查询,包括正则表达式的应用。同时,讲解了如何通过节点索引和方法访问子节点、属性和文本。"
16951651,1376248,cocos2d-X UIInputManager.h API详解,"['cocos2d-x', '游戏开发', 'API接口']
最低0.47元/天 解锁文章
924

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



