四将爬取的信息存储到本地
之前我们都是将爬取的数据直接打印到了控制台上,这样显然不利于我们对数据的分析利用,也不利于保存,所以现在就来看一下如何将爬取的数据存储到本地硬盘。
1 对.txt文件的操作
读写文件是最常见的操作之一,python3 内置了读写文件的函数:open open(file, mode='r', buffering=-1, encoding=None, error
s=None, newline=None, closefd=True, opener=None))O
pen file and return a corresponding file object. If the file
cannot be opened, an OSErroris raised.