![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python爬虫
vaeloverforever
黑暗总会过去的
展开
-
利用BeautifulSoup爬取网页内容
利用BeautifulSoup可以很简单的爬取网页上的内容。这个套件可以把一个网页变成DOM Tree 要使用BeautifulSoup需要使用命令行进行安装,不过也可以直接用python的ide。 基础操作 : ① 使用之前需要先从bs4中导入包:from bs4 import BeautifulSoup ② 使用的代码:soup = BeautifulSoup(res.t...原创 2018-10-05 21:02:42 · 5568 阅读 · 0 评论 -
爬虫实战--爬取CPU天梯榜单
网址: http://itianti.sinaapp.com/index.php/mcpu 最近女票要买电脑,看了几款,于是我就帮她看看这几款的CPU咋样,就找了一个CPU天梯排行榜。一瞅发现,榜上有800+个CPU,一个一个找,得累死。刚好最近了解了python爬虫,于是乎,就写了一个爬虫脚本,把排名和CPU名字爬了并且保存下来了。 代码如下: import requests ...原创 2018-11-01 16:19:35 · 927 阅读 · 0 评论 -
爬取网页的标题、时间、来源 、正文、作者、评论数、新闻id
# coding: utf-8 # In[4]: #导入包 import requests from bs4 import BeautifulSoup #爬取特定网页 res = requests.get("https://news.sina.com.cn/china/") #转化文字编码 res.encoding = 'utf-8' #存进BeautifulSoup元素中 soup =...原创 2018-11-03 15:13:56 · 5847 阅读 · 0 评论