每日一爬
每日一爬
将抓取到的数据清晰的展示到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'