每日一爬

每日一爬

将抓取到的数据清晰的展示到data.csv中 需要导包

f = open("data.csv",mode="w",encoding= 'utf-8')
csv_writer = csv.writer(f)

for i in result:
  # print(i.group("name"))
  # print(i.group("year").strip())
  # print(i.group("pf"))
  # print(i.group("pj"))
  dic = i.groupdict()
  dic['year'] = dic['year'].strip()
  csv_writer.writerow(dic.values())
f.close()
print("over!")

此类报错是有安全验证

verify = False 去掉安全验证

resp = requests.get(domain,verify=False) # verify = False  去掉安全验证

 

出现乱码情况 变量名.encoding = 'gbk'

posted @ 2021-06-09 20:36  测试小能手1  阅读(75)  评论(0编辑  收藏  举报