wnma3mz/wechat_articles_spider

html输出中图片地址错误

Nek0-hinata opened this issue · 1 comments

image
在使用url2html时,html中出现的斜杠导致图片无法正常显示,对主代码没有任何更改

感谢提醒,现将保存图片路径写死,图片文件放在对应公众号名称中的文件夹的imgs

save_path = os.path.join(self.account, "imgs", name)
# 如果该图片已被下载,可以无需再下载,直接返回路径即可
if os.path.isfile(save_path):
with open(save_path, "rb") as f:
img = f.read()
return os.path.join("imgs", name), img
response = requests.get(url, proxies=self.proxies)
img = response.content
with open(save_path, "wb") as f:
f.write(img)
return os.path.join("imgs", name), img