Python3爬虫--BeautifulSoup
1、 首先,安装bs4模块,该模块包含BeautifulSoup库。Windows下进入dos中,敲入以下命令:
>>>pip install bs4
本机已经安装成功,因此图片可能有些区别。


2、>>>python
敲入命令回车进入Python交互模式,敲入以下命令
>>>from bs4 import BeautifulSoup

3、>>>from urllib.request import urlopen
>>>html = urlopen("https://baike.baidu.com/")
>>>bsObj = BeautifulSoup(html.read())
图中表示网页的内容已经转化为了BeautifulSoup对象。

4、>>>bsObj.div.a
从网页中提取第一个div中的<a>标签成功
>>>bsObj


阅读量:172
阅读量:24
阅读量:104
阅读量:90
阅读量:70