爬虫实战
今天的任物是通过requests + bs4 & lxml 这三个库来完成爬取丁香园论坛的回复内容首先我们说一下数据 这里的数据包含了 标题 楼主提问的问题内容 以及各楼层的回复内容(title author_say recovery) 这三个内容 bs4 以及lxml 的文档较为玩整这里就不多做赘述,有需要可以去查看文档 bs4 lxml 笔者这里较为常用的爬虫库是bs4,lxml多数用来读取较大的lxml
BeautifulSoup
from bs4 import BeautifulSoup
import requests
url = 'http://www.dxy.cn/bbs/thread/626626#626626'
response = requests.get(url)
html = response.text
soup = BeautifulSoup(html
665



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



