之前lz在用scrapy对链家进行爬取的时候,将数据保存到mysql数据库中,发现如果不修改字符集的格式,那么默认就是gbk,就会不支持中文,那么就需要将其更改为utf-8的格式。这就需要在mysql创建表的时候,将默认的字符格式指定为utf-8格式,有助于对中文的支持。具体的执行如下所示:
create table music_review_douban ( id int auto_increment not null primary key, review_title text, review_content text, review_author text, review_music text, review_time text, review_url text ) engine = innodb character set utf8;
在最后需要指定数据库的引擎和字符为utf-8。