1,爬取多数据的时候会出现突然中断的问题
尝试把UserAgent增多后排除
使用方法
from fake_useragent import UserAgent
最好是下载后再安装,phpstrome安装会有bug
使用时需要设置
ua = UserAgent(use_cache_server=False)
self.headers ={
'User-Agent':ua.random
}
不然会出现问题
2,去除转义符
def clear_str(self,data):
clear_str = re.compile(r'\n| |\xa0|\\xa0|\u3000|\\u3000|\\u0020|\u0020|\t|\r').sub('',data)
return clear_str