一、创建python文件,导入相关的库
1.1 导入BeautifulSoup4、requests、lmxl库
import requests
from bs4 import BeautifulSoup
from lxml import html
附1:BeautifulSoup4文档:
https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html
1.2 实现代码:
指定url =“要爬取网页的网址”
![](https://img.haomeiwen.com/i9535648/985c6b32f935db03.png)
1.3 print(result)便输出了爬取的内容。
![](https://img.haomeiwen.com/i9535648/fdf4dfb29a74cf03.png)
网友评论