记录常用的爬虫代码段(长期更新)

判断文件路径不存在创建文件路径

    if not osp.exists(path):
            os.makedirs(path)

  

去除字符串非法字符,防止创建文件夹报错

    #去掉非法字符
            pitow = re.sub('[\/:*?"<>|]','-',name)

  

posted @ 2023-04-19 20:21    阅读(6)  评论(0编辑  收藏  举报